1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- /**
- * @file testSegmentation.cpp
- * @brief test segmentation algorithm
- * @author Björn Fröhlich
- * @date 01/20/2010
- */
- #include <objrec/nice.h>
- #include <objrec/baselib/Config.h>
- #include <list>
- 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<int> 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;
- }
|