From 5c92798ac85295a5fe6c234cf32c79fa3a7c4d8c Mon Sep 17 00:00:00 2001 From: mutantturkey Date: Fri, 15 Jun 2012 23:47:55 -0400 Subject: added getops handling for FilterFlymask --- fly-tools/FilterFlyMask.cpp | 64 +++++++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 26 deletions(-) diff --git a/fly-tools/FilterFlyMask.cpp b/fly-tools/FilterFlyMask.cpp index 8ecb55b..40d25e3 100644 --- a/fly-tools/FilterFlyMask.cpp +++ b/fly-tools/FilterFlyMask.cpp @@ -135,27 +135,46 @@ void writeHist(const char* filename, map & len) int main(int argc, char* argv[]) { - if (argc < 5) - { - - cerr << "Usage: executablename " << endl; // input file contains name of the - // input image files - return -1; - } - + string usage = "Usage: FilterFlyMask -f -r -m -o "; + string fileName; + string inputMaskFileLocation; + string outputFileLocation; + double ratioSecondLargestToLargest; + int c; + opterr = 0; + + while ((c = getopt (argc, argv, "m:f:r:o:hv")) != -1) + switch (c) + { + case 'f': + fileName = optarg; + break; + case 'm': + inputMaskFileLocation = optarg; + break; + case 'r': + ratioSecondLargestToLargest = atof(optarg); + break; + case 'o': + outputFileLocationi = optarg; + break; + case 'v': + break; + case 'h': + cout << usage << endl; + exit(1); + break; + defaut: + break; + } + + if( fileName.empty() || inputMaskFileLocation.empty() || ratioSecondLargestToLargest == NULL || outputFileLocation.empty()) { + cout << usage << endl; + exit(1); + } //MagickCore::SetMagickResourceLimit(MagickCore::MemoryResource, 1536); //MagickCore::SetMagickResourceLimit(MagickCore::MapResource, 2048); - - // Arg 1 is a file name, this is the actual name (First10MinSet48_0000001.png) - string fileName = argv[1]; - // Arg 2 is the ratio of the second largest to largest. Use 15. - double ratioSecondLargestToLargest = atof(argv[2]); - // Arg 3 is the location of the Masks - string inputMaskFileLocation(argv[3]); - // Arg 4 is the output folder for the Filtered images. - string outputFileLocation(argv[4]); - ratioSecondLargestToLargest = 1/ratioSecondLargestToLargest; char buffer[100]; @@ -233,7 +252,6 @@ int main(int argc, char* argv[]) } } - bubbleSort(); // take the largest object @@ -309,17 +327,11 @@ int main(int argc, char* argv[]) void findObjIterative(Image* img, int x, int y, vector > & shape, bool eightCon, double colorLookingFor) { assert(imgForFilter != NULL); - - //if (eightCon == true) - // eightConnObjIterative(img, x, y, shape, colorLookingFor); - //else { fourConnObjIterative(img, x, y, shape, colorLookingFor); - //} - - } + void fourConnObjIterative(Image* img, int x, int y, vector > & obj, double colorLookingFor) { /* -- cgit v1.2.3