/** * @file testSegmentation.cpp * @brief test segmentation algorithm * @author Björn Fröhlich * @date 01/20/2010 */ #include #include #include using namespace OBJREC; using namespace NICE; using namespace std; int main (int argc, char **argv) { if(argc < 1) { cerr << "Bitte Bild angeben" << endl; return -1; } string filename; filename += argv[1]; //RSMeanShift rg; NICE::Image img; img.read(filename); NICE::Image out(img); int masksize = 5; int mh = masksize/2; int width = img.width(); int height = img.height(); for(int x= 0; x < width; x++) { for(int y = 0; y < height; y++) { vector nh; for(int i = -mh; i <= mh; i++) { for(int j = -mh; j <= mh; j++) { int xpos = x + i; int ypos = y + j; if(xpos < 0 || ypos < 0 || xpos >= width || ypos >= height) continue; nh.push_back(img.getPixel(xpos,ypos)); } } sort(nh.begin(), nh.end()); int val = nh[nh.size()/2]; out.setPixel(x,y,val); } } out.write("res.ppm"); return 0; }