Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*********************************************************************/
- /* vmed Compute local 1x1x3 median using the buffer method */
- /*********************************************************************/
- #include "VisXV4.h" /* VisionX structure include file */
- #include "Vutil.h" /* VisionX utility header files */
- VXparam_t par[] = /* command line structure */
- {
- { "if=", 0, " input file vssum: compute temporal mean"},
- { "of=", 0, " output file "},
- { 0, 0, 0}
- };
- #define IVAL par[0].val
- #define OVAL par[1].val
- #define max(x,y) ((x) >= (y)) ? (x):(y)
- #define min(x,y) ((x) <= (y)) ? (x):(y)
- int
- main(argc, argv)
- int argc;
- char *argv[];
- {
- V3fstruct (im);
- V3fstruct (tm);
- int x,y,z; /* index counters */
- int total;
- int maxi;
- int mini;
- VXparse(&argc, &argv, par); /* parse the command line */
- while (Vbfread( &im, IVAL, 3)) {
- if ( im.type != VX_PBYTE || im.chan != 1) { /* check format */
- fprintf (stderr, "image not byte type\n");
- exit (1);
- }
- V3fembed(&tm, &im, 1,1,1,1,1,1);
- for (y = im.ylo; y <= im.yhi; y++) {
- for (x = im.xlo; x <= im.xhi; x++) {
- total = tm.u[0][y][x]+ tm.u[1][y][x]+ tm.u[2][y][x];
- mini = min(tm.u[0][y][x], min(tm.u[1][y][x],tm.u[2][y][x]));
- maxi = max(tm.u[0][y][x], max(tm.u[1][y][x],tm.u[2][y][x]));
- im.u[0][y][x]= total-mini-maxi;
- }
- }
- V3fwrite (&im, OVAL); /* write the oldest frame */
- }
- exit(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement