AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2009.04.28 18:15 "[Tiff] Libtiff and OpenCV", by Andreas H.
2009.04.28 19:05 "Re: [Tiff] Libtiff and OpenCV", by Frank Warmerdam
2009.04.28 20:33 "Re: [Tiff] Libtiff and OpenCV", by Andreas H.
2009.04.29 02:32 "Re: [Tiff] Libtiff and OpenCV", by Kai-Uwe Behrmann
2009.04.29 07:37 "Re: [Tiff] Libtiff and OpenCV", by Andreas Heindl
2009.04.29 08:48 "Re: [Tiff] Libtiff and OpenCV", by Kai-Uwe Behrmann
2009.04.29 16:07 "Re: [Tiff] Libtiff and OpenCV", by Bob Friesenhahn

2009.04.28 18:15 "[Tiff] Libtiff and OpenCV", by Andreas H.

Hi,

I'm stuck and I hope some of you can give me an advise. I use libtiff because opencv cannot read my source tif images.

My original image is stored in img. I use the code snipped beneath for converting the imageData (char buffer) to a uint8 buffer named TIFFImageData

IplImage* img;
.
.
.

  TIFFImageData = (uint8*) _TIFFmalloc(width*height * sizeof (uint8));
// allocate temp memory

     for (int x = 0; x < w; x++) {
            // printf("loop...%d to %d\n",count++,w);
            for (int y = 0; y < h; y++) {

                TIFFImageData[h * x + y] =  (uint8) img->imageData[h *

x + y]; // Copy data from ipl to tif
            }

        }

Afterward I want to write TIFFImageData to my new TIF (that will consist of many of my source tif images) using WriteTileToTiff below.

int WriteTileToTiff(TIFF* tif, uint8* buf, long size, int x, int y){
    if (tif) {
        tsize_t tilenumber = -1;
        tsize_t writtendata = -1;

        writtendata=TIFFWriteTile(tif,buf,x,y,0,NULL);

        printf("%d data written to new tif \n",writtendata);
        if (writtendata==-1){
            printf("[ERROR] TIFFWriteEncodedTile returned -1...\n");
        }

        TIFFClose(tif);
        return 0;
    }else{
        return -1;
    }
  return -1;
}

The result is a strange looking tiff, like if I did something wrong during converting. My source image is an 8-Bit grayscale tif.

andreas@host:$ identify real_604.tif real_604.tif TIFF 1392x1024 1392x1024+0+0 PseudoClass 256c 8-bit 120.99kb

Thanks in advance for your help,

Andreas