AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2001.02.20 16:08 "need help", by Chakravarthy Terlapu
2001.02.20 17:19 "Re: need help", by Leonard Rosenthol
2001.03.02 15:12 "doubt", by Chakravarthy Terlapu
2001.03.05 20:54 "erasing pixels within a box using TIFF library", by Chakravarthy Terlapu
2001.03.06 20:47 "Re: erasing pixels within a box using TIFF library", by Chris 'Xenon' Hanson

2001.02.20 16:08 "need help", by Chakravarthy Terlapu

Hi,

I have a image called street.tif and 2 boxes whose coordinates are for
example as follows;

//Box1

frc[i].lx = x1;   //left x-coordinate        
frc[i].ly = y1;   //left y-coordinate   
frc[i].tx = x2;   //top x-coordinate   
frc[i].ty = y2;   //top y-coordinate   
frc[i].rx = x3;   //right x-coordinate   
frc[i].ry = y3;   //right y-coordinate 
frc[i].bx = x4;   //bottom x-coordinate 
frc[i].by = y4;   //bottom y-coordinate 

//Box2
frc[i].lx = x11;
frc[i].ly = y11;
frc[i].tx = x22;
frc[i].ty = y22;
frc[i].rx = x33;
frc[i].ry = y33;
frc[i].bx = x44;
frc[i].by = y44;

I need to create a new image say street1.tif which contains
street.tif - boxes i.e I have to erase all pixels within the
box1 and box2.

It would be great if anyone could help me.

THanks
Chakravarthy Terlapu

#include "tiffio.h"
#include <stdio.h>

main()
{
  int i,j,k;
  unsigned short t;
  int linebytes, outbytes;
  uint32 w,h;
  uint32 row;
  unsigned char *inbuf,*outbuf;

TIFF* in;
TIFF* out;

in=TIFFOpen("street.tif","r");
out=TIFFOpen("street1.tif","w");

TIFFGetField(in, TIFFTAG_IMAGELENGTH, &h);

TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &w);

  TIFFSetField(out, TIFFTAG_IMAGELENGTH, h);
  TIFFSetField(out, TIFFTAG_IMAGEWIDTH, w);
  TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 1);
  TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 1);

TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);

TIFFSetField(out, TIFFTAG_ORIENTATION, 1);

linebytes=TIFFScanlineSize(in);
outbytes=TIFFScanlineSize(out);

inbuf=_TIFFmalloc(linebytes);
outbuf=_TIFFmalloc(outbytes);

 for(row=0; row<h; i++)
 {
   TIFFReadScanline(in, inbuf, row, 0);

   //Here how can I do the processing of removing the pixels within the box

   TIFFWriteScanline(out, inbuf, row, 0 );
 }
TIFFClose(in);
TIFFClose(out);

  free(inbuf);
  free(outbuf);
}