| AWARE [SYSTEMS] | Imaging expertise for the Delphi developer | |||||||
![]() |
TIFF and LibTiff Mailing List Archive | |||||||
LibTiff Mailing List
TIFF and LibTiff Mailing List Archive Contact
The TIFF Mailing List Homepage |
Thread2009.04.28 19:05 "Re: Libtiff and OpenCV", by Frank WarmerdamAndreas 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
|
|||||||