Advertisement
sam2708

invert

Nov 15th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.97 KB | None | 0 0
  1. 1/*******************************************************************/
  2. 2/* invert      Invert Pixels to Make Background Dark   */
  3. 3/*******************************************************************/
  4. 4.   
  5. 5#include "VisXV4.h"           /* VisionX structure include file    */
  6. 6#include "Vutil.h"            /* VisionX utility header files      */
  7. 7#include "stdlib.h"
  8. 8.   
  9. 9VXparam_t par[] =             /* command line structure            */
  10. 10. { /* prefix, value,   description                         */  
  11. 11. {    "if=",    0,   " input file  vtemp: local max filter "},
  12. 12. {    "of=",    0,   " output file "},
  13. 13. {     0,       0,   0}  /* list termination */
  14. 14. };
  15. 15. #define  IVAL   par[0].val
  16. 16. #define  OVAL   par[1].val
  17. 17.  
  18. 18. main(argc, argv)
  19. 19. int argc;
  20. 20. char *argv[];
  21. 21. {
  22. 22. Vfstruct (im);                      /* i/o image structure          */
  23. 23. Vfstruct (tm);                      /* temp image structure         */
  24. 24.
  25. 25. int        y,x;                     /* index counters               */
  26. 26.   VXparse(&argc, &argv, par);       /* parse the command line       */
  27. 27.  
  28. 28.   Vfread(&im, IVAL);                /* read image file              */
  29. 29.   Vfembed(&tm, &im, 1,1,1,1);       /* image structure with border  */
  30. 30.   Vfembed(&im2, &im, 1,1,1,1);       /* image structure with border  */
  31. 31.   if ( im.type != VX_PBYTE ) {      /* check image format           */
  32. 32.      fprintf(stderr, "vtemp: no byte image data in input file\n");
  33. 33.      exit(-1);
  34. 34.   }
  35. 35.   for (y = im.ylo ; y <= im.yhi ; y++) {  /* compute the function */
  36. 36.      for (x = im.xlo; x <= im.xhi; x++)  {    
  37. 37.         if (tm.u[y][x] < 20){      
  38. 38.             im.u[y][x] = 0;      
  39. 39.          }
  40. 40.          else  {
  41. 41.              im.u[y][x] = 255;      
  42. 42.          }    
  43. 43.      }
  44. 44.   }
  45. 45.  
  46. 46.        
  47. 47.    Vfwrite(&im, OVAL);             /* write image file                */
  48. 48.    exit(0);
  49. 49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement