Advertisement
Guest User

Untitled

a guest
Oct 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. /*********************************************************************/
  2. /* vmed Compute local 1x1x3 median using the buffer method */
  3. /*********************************************************************/
  4.  
  5. #include "VisXV4.h" /* VisionX structure include file */
  6. #include "Vutil.h" /* VisionX utility header files */
  7. VXparam_t par[] = /* command line structure */
  8. {
  9. { "if=", 0, " input file vssum: compute temporal mean"},
  10. { "of=", 0, " output file "},
  11. { 0, 0, 0}
  12. };
  13. #define IVAL par[0].val
  14. #define OVAL par[1].val
  15. #define max(x,y) ((x) >= (y)) ? (x):(y)
  16. #define min(x,y) ((x) <= (y)) ? (x):(y)
  17. int
  18. main(argc, argv)
  19. int argc;
  20. char *argv[];
  21. {
  22. V3fstruct (im);
  23. V3fstruct (tm);
  24.  
  25. int x,y,z; /* index counters */
  26. int total;
  27. int maxi;
  28. int mini;
  29. VXparse(&argc, &argv, par); /* parse the command line */
  30.  
  31. while (Vbfread( &im, IVAL, 3)) {
  32. if ( im.type != VX_PBYTE || im.chan != 1) { /* check format */
  33. fprintf (stderr, "image not byte type\n");
  34. exit (1);
  35. }
  36. V3fembed(&tm, &im, 1,1,1,1,1,1);
  37. for (y = im.ylo; y <= im.yhi; y++) {
  38. for (x = im.xlo; x <= im.xhi; x++) {
  39. total = tm.u[0][y][x]+ tm.u[1][y][x]+ tm.u[2][y][x];
  40. mini = min(tm.u[0][y][x], min(tm.u[1][y][x],tm.u[2][y][x]));
  41. maxi = max(tm.u[0][y][x], max(tm.u[1][y][x],tm.u[2][y][x]));
  42. im.u[0][y][x]= total-mini-maxi;
  43. }
  44. }
  45.  
  46. V3fwrite (&im, OVAL); /* write the oldest frame */
  47. }
  48. exit(0);
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement