/*********************************************************************/ /* vcmean Compute channel mean */ /*********************************************************************/ #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 "}, { 0, 0, 0} }; #define INIMAGE par[0].val #define OUTIMAGE par[1].val int main(int argc, char** argv) { Vfstruct (im); Vfstruct (om); int x, y, c; int thresh; int chan, sum; VXparse(&argc, &argv, par); /* parse the command line */ while ( Vfread( &im, INIMAGE) ) { if ( im.type != VX_PBYTE ) { fprintf (stderr, "error: image not byte type\n"); exit (1); } Vfnewim (&om, VX_PBYTE, im.bbx, 1); for ( y = om.ylo; y <= om.yhi; y++) { for ( x = om.xlo; x <= om.xhi; x++) { sum = 0; for ( c = 0; c < im.chan; c++) { sum = sum + im.u[y][x * im.chan + c]; } om.u[y][x] = sum / im.chan; } } Vfwrite( &im, OUTIMAGE); } exit(0); }