Removed commented code in binarize

This commit is contained in:
Matt Hill
2014-01-19 11:02:48 -06:00
parent b759db9717
commit e1af64fcb1

View File

@@ -217,156 +217,3 @@ void NiblackSauvolaWolfJolion (Mat im, Mat output, NiblackVersion version,
} }
} }
} }
/**********************************************************
* The main function
**********************************************************/
/**********************************************************
* Usage
**********************************************************/
/*
static void usage (char *com) {
cerr << "usage: " << com << " [ -x <winx> -y <winy> -k <parameter> ] [ version ] <inputimage> <outputimage>\n\n"
<< "version: n Niblack (1986) needs white text on black background\n"
<< " s Sauvola et al. (1997) needs black text on white background\n"
<< " w Wolf et al. (2001) needs black text on white background\n"
<< "\n"
<< "Default version: w (Wolf et al. 2001)\n"
<< "\n"
<< "example:\n"
<< " " << com << " w in.pgm out.pgm\n"
<< " " << com << " in.pgm out.pgm\n"
<< " " << com << " s -x 50 -y 50 -k 0.6 in.pgm out.pgm\n";
}
int main (int argc, char **argv)
{
char version;
int c;
int winx=0, winy=0;
float optK=0.5;
bool didSpecifyK=false;
NiblackVersion versionCode;
char *inputname, *outputname, *versionstring;
cerr << "===========================================================\n"
<< "Christian Wolf, LIRIS Laboratory, Lyon, France.\n"
<< "christian.wolf@liris.cnrs.fr\n"
<< "Version " << BINARIZEWOLF_VERSION << endl
<< "===========================================================\n";
// Argument processing
while ((c = getopt (argc, argv, "x:y:k:")) != EOF) {
switch (c) {
case 'x':
winx = atof(optarg);
break;
case 'y':
winy = atof(optarg);
break;
case 'k':
optK = atof(optarg);
didSpecifyK = true;
break;
case '?':
usage (*argv);
cerr << "\nProblem parsing the options!\n\n";
exit (1);
}
}
switch(argc-optind)
{
case 3:
versionstring=argv[optind];
inputname=argv[optind+1];
outputname=argv[optind+2];
break;
case 2:
versionstring=(char *) "w";
inputname=argv[optind];
outputname=argv[optind+1];
break;
default:
usage (*argv);
exit (1);
}
cerr << "Adaptive binarization\n"
<< "Threshold calculation: ";
// Determine the method
version = versionstring[0];
switch (version)
{
case 'n':
versionCode = NIBLACK;
cerr << "Niblack (1986)\n";
break;
case 's':
versionCode = SAUVOLA;
cerr << "Sauvola et al. (1997)\n";
break;
case 'w':
versionCode = WOLFJOLION;
cerr << "Wolf and Jolion (2001)\n";
break;
default:
usage (*argv);
cerr << "\nInvalid version: '" << version << "'!";
}
cerr << "parameter k=" << optK << endl;
if (!didSpecifyK)
cerr << "Setting k to default value " << optK << endl;
// Load the image in grayscale mode
Mat input = imread(inputname,CV_LOAD_IMAGE_GRAYSCALE);
if ((input.rows<=0) || (input.cols<=0)) {
cerr << "*** ERROR: Couldn't read input image " << inputname << endl;
exit(1);
}
// Treat the window size
if (winx==0||winy==0) {
cerr << "Input size: " << input.cols << "x" << input.rows << endl;
winy = (int) (2.0 * input.rows-1)/3;
winx = (int) input.cols-1 < winy ? input.cols-1 : winy;
// if the window is too big, than we asume that the image
// is not a single text box, but a document page: set
// the window size to a fixed constant.
if (winx > 100)
winx = winy = 40;
cerr << "Setting window size to [" << winx
<< "," << winy << "].\n";
}
// Threshold
Mat output (input.rows, input.cols, CV_8U);
NiblackSauvolaWolfJolion (input, output, versionCode, winx, winy, optK);
// Write the tresholded file
cerr << "Writing binarized image to file '" << outputname << "'.\n";
imwrite (outputname, output);
return 0;
}
*/