#include "VisXV4.h" /* VisionX structure include file */ #include "Vutil.h" /* VisionX utility header files */ VXparam_t par[] = /* command line structure */ { { "if=", 0, " input file vthresh: threshold images"}, { "of=", 0, " output file "}, { "th=", 0, " Threshold value (default 50)"}, { 0, 0, 0} }; #define INIMAGE par[0].val #define OUTIMAGE par[1].val #define THRESHOLD par[2].val int main(int argc, char** argv) { Vfstruct (im); int x, y; int thresh; VXparse(&argc, &argv, par); /* parse the command line */ if (THRESHOLD ) { thresh = atoi (THRESHOLD); } else { thresh = 50; } while ( Vfread( &im, INIMAGE) ) { if ( im.type != VX_PBYTE ) { fprintf (stderr, "error: image not byte type\n"); exit (1); } for ( y = im.ylo; y <= im.yhi; y++) { for ( x = im.xlo; x <= im.xhi; x++) { im.u[y][x] = im.u[y][x] >= thresh ? 255 : 0; } } Vfwrite( &im, OUTIMAGE); } exit(0); }