2009.04.28 19:05 "Re: [Tiff] Libtiff and OpenCV", by Frank Warmerdam
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
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