/////////////////////////////////////////////////////////////////////////// // // NAME // main.cpp -- entry point for segmentation code. Also analyzes regions // // USAGE // Segmenter input.ppm iters difThresh segThresh mergeThresh [colorByIndex] // // iters - number of iterations of anisotropic diffusion (try 10..20) // difThresh - when to use all 8 rather than 3 neighbors in diffusion (try 0..10) // segThresh - how different colors in one segment can be (try 10..50) // mergeThresh - threshold for difference accross boundary for merging (try 5..20) // colorByIndex - if 1, use index for coloring, otherwise (default) average colors // // SEE ALSO // Segmentation.cpp // // Copyright © Timothy Bahls, Daniel Scharstein, 2004. // /////////////////////////////////////////////////////////////////////////// #include #include #include "Image.h" #include "ImageIO.h" #include "Error.h" #include "SegXYT.h" #include "Utils.h" #include "PhotoAnalysis.h" #include "Rasterizor2D.h" bool verbose = true; // print progress to stderr bool stereo = true; bool output=true; bool concave=false; //int segment=0; bool dataSet=false; char* dataSetName; int main(int argc, char *argv[]) { try { if (argc < 8&&argc!=3&&argc!=4) { fprintf(stderr, "usage: Segment.exe input frames iters difThresh segThresh \n mergeThresh minSize [colorByIndex]\nor: Segment.exe input frames"); exit(1); } int segment=0; int argn = 0; char *infilename = argv[++argn]; int nFrames = atoiSafe(argv[++argn]); CByteImage *im= new CByteImage[nFrames]; CByteImage *colseg=new CByteImage[nFrames]; if(argc>argn+2){ segment=1; int iters = atoiSafe(argv[++argn]); int difThresh = atoiSafe(argv[++argn]); int segThresh = atoiSafe(argv[++argn]); int mergeThresh = atoiSafe(argv[++argn]); int minSize = atoiSafe(argv[++argn]); int colorByIndex = 0; if (argc > argn+1) colorByIndex = atoiSafe(argv[++argn]); for(int f=0; fargn+1){ dataSet=true; dataSetName = argv[++argn]; } CByteImage *orig=new CByteImage[nFrames]; for(int f=0; f