|
degate 0.1.1
|
00001 /* -*-c++-*- 00002 00003 This file is part of the IC reverse engineering tool degate. 00004 00005 Copyright 2008, 2009, 2010 by Martin Schobert 00006 00007 Degate is free software: you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation, either version 3 of the License, or 00010 any later version. 00011 00012 Degate is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with degate. If not, see <http://www.gnu.org/licenses/>. 00019 00020 */ 00021 00022 #ifndef __SUBIMAGEANALYZER_H__ 00023 #define __SUBIMAGEANALYZER_H__ 00024 00025 00026 #include <vector> 00027 #include <algorithm> 00028 #include <iostream> 00029 00030 #include <Image.h> 00031 #include <TypeConstraints.h> 00032 00033 namespace degate { 00034 00035 template<typename ImageType> 00036 class SubImageAnalyzer { 00037 00038 private: 00039 std::tr1::shared_ptr<ImageType> img; 00040 unsigned int width; 00041 00042 public: 00043 SubImageAnalyzer(std::tr1::shared_ptr<ImageType> _img, 00044 unsigned int width) : 00045 img(_img), 00046 width(_width) { 00047 00048 assert_is_multi_channel_image<ImageType>(); 00049 } 00050 00051 void run() { 00052 00053 std::vector<rgba_pixel_t> v(width * width); 00054 00055 int radius = width >> 1; 00056 unsigned int i = 0; 00057 00058 for(unsigned int y = width; y < img->get_height() - radius; y++) 00059 for(unsigned int x = width; x < img->get_width() - radius; x++, i++) { 00060 00061 for(int _y = -radius; _y < radius; _y++) 00062 for(int _x = -radius; _x < radius; _x++) { 00063 rgba_pixel_t p = img->get_pixel(x + _x, y + _y); 00064 vector[i] = p; 00065 } 00066 } 00067 00068 virtual bool calc(std::vector<rgba_pixel_t> const& v) const = 0; 00069 } 00070 00071 }; 00072 00073 00074 } 00075 00076 #endif
1.7.4