Advertisement
sam2708

invert

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