[gdal-dev] Problem with 4 bands Jpeg2000 files using GDAL + Erdas ECW4.3 Read-only

Even Rouault even.rouault at mines-paris.org
Wed Oct 9 06:41:55 PDT 2013


Le mercredi 09 octobre 2013 09:42:26, victor fomin a écrit :
> Dear gdal-developers,
> 
> I noticed a strange behaviour while reading Pleaides Jpeg2000 4 bands EO
> products using overviews. I use GDAL 1.10.1 with Erdas ECW4.3 to support
> jpeg2000 files. The following code
> 
> GDALDataset * dataset = static_cast<GDALDataset *>(GDALOpen(inputFilename,
> GA_ReadOnly));
> 
> < Image has : 4 bands, and WxH : 10296, 6573>
> < Image DataType : GDT_UInt16>
> <define parameters : offset={0,0}, desiredNbOfSamples=167424,
> data.width=500, data.height=400>
> 
> // Just get and show twice the same data :
> for (int index = 0; index < 2; index++)
> {
> int pixelSizeInBytes = nbBands * 8;
> int rowSizeInBytes = pixelSizeInBytes * data.width;
> for (int band=1;band<=nbBands;band++)
> 
> {
> 
>      GDALRasterBand* rasterBand = dataset->GetRasterBand(band)->
> GetRasterSampleOverview(desiredNbOfSamples);
>      rasterBand->RasterIO( GF_Read, offset[0], offset[1], data.width, data.
> height,
>                               data.buffer + 8*(band - 1), data.width, data.
> height, GDT_Float64, pixelSizeInBytes, rowSizeInBytes );
> }
> showData(data);
> 
> }
> GDALClose(dataset);
> 
> The result of the code is intended to show twice the same data, however the
> result is that the first shown image is correct and the second image is
> horizontally distorted (compressed) as 1/4 of the good width.
> Could anyone, please explain me whether I missed something ?

Victor,

I don't see at first anything obviously wrong in your code snippet, but there's 
still an odd thing, the fact that you use GetRasterSampleOverview(). If you do 
so, it is a bit difficult to guess the correct source window. Using RasterIO() 
on the base band and expressing the source window and output buffer size might 
be more natural, and RasterIO() will select the appropriate overview level. 
But that shouldn't really explain the phenomenon you see.

If you believe there's an issue in GDAL, I'd encourage you reducing your test 
case to an antonomous and minimal code snippet (i.e. that can be compiled 
standalone), and that doesn't use showData() but just compares with memcmp() 
the content of the buffers from the 2 loops.

Even

-- 
Geospatial professional services
http://even.rouault.free.fr/services.html


More information about the gdal-dev mailing list