AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
April 2009

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

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

2009.04.28 19:05 "Re: Libtiff and OpenCV", by Frank Warmerdam

Andreas H. wrote:
> 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
>             }
> 
>         }

Andreas,

TIFF images are normally (always?) stored with a row of values together,
followed by the next row, etc.  So the above would need to have x and y
reversed in handling. Something like:

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

If you get this wrong, your images will be bizzarely skewed.  I'm assuming
your interpretation of your source buffer is correct.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam@pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent