Zermeno, Robert J CIV NAVAIR, 472100D wrote:
GDAL club,

I am using a test image, called world.jp2, you could download from 
http://www.microimages.com/gallery/jp2/, specifically, 
http://www.microimages.com/gallery/jp2/1.jp2.  I have made my own application 
to provide block segments viewing capabilities in both .jp2 and .tif format.

I converted this file, world.jp2 to world.tif, to test my code.  Objective is 
get a block of image data given xoff,yoff,xsize,ysize.  If the parameters go 
outside bounds, I manually readjust the xsize and ysize to what was given to 
what GDAL can actually retrieve using the xoff,yoff as my origin for new image.

This code works for .tif images.  I have tested it thoroughly and have not had 
any problems.  For .jp2 files, Whenever I acquire the bottom region of the 
file, the remaining 10 lines or so of the image, GDALRasterIO() returns bad 
values but it still does not give me an error.  Can someone duplicate this test 
case.  I believe it should be a new ticket, but I need confirmation first.

Detailed example test case that provides bad output: JPEG2000 Driver Using: KAKADU
File name: World.jp2
Size: Width = 800 Heigth = 400
pixelOffset = 0
lineOffset  = 100
usrImageWidth = 512
UsrImageHeight = 300

This will grab the bottom left corner of the image.  It correctly gives me the 
image data all the way up to approx. line 285 or 295...


Robert,

I fetched the file, and tried this gdal_translate command without any
apparent problems:

  gdal_translate -srcwin 0 100 512 300 1.jp2 out.tif

I skimmed your code and didn't see any issues, but I did not take the time
to review it carefully.  I'd encourage you to try and reproduce the problem
with gdal_translate.  You might also want to try enabling debugging to get
an idea of what is going on internally.  For gdal_translate this can be
done by including "--debug on" on the commandline.  For your own program
you could do it by ensuring the CPL_DEBUG environment variable is set to ON.

I see something like:

warme...@gdal64[113]% gdal_translate -srcwin 0 100 512 300 1.jp2 out.tif
JP2KAK: Using 1 threads.
JP2KAK: Cuse_precincts=0, PreferNonPersistentReads=0
JP2KAK: order=LRCP
JP2KAK: ycc=true
JP2KAK: nResCount=2
GDAL: GDALOpen(1.jp2, this=0x204dc00) succeeds as JP2KAK.
Input file size is 800, 400
GDAL: QuietDelete(out.tif) invoking Delete()
GDAL: GDALOpen(out.tif, this=0x20682a0) succeeds as GTiff.
GDAL: GDALClose(out.tif, this=0x20682a0)
0GDAL: GDALOpen(GTIFF_RAW:out.tif, this=0x2067ca0) succeeds as GTiff.
GDAL: GDALDatasetCopyWholeRaster(): 512*300 swaths, bInterleave=1
JP2KAK: DirectRasterIO() for 0,100,512,300 -> 512x300 (no intermediate)
JP2KAK: DirectRasterIO() for 0,100,512,300 -> 512x300 (no intermediate)
JP2KAK: DirectRasterIO() for 0,100,512,300 -> 512x300 (no intermediate)
...10...20...30...40...50...60...70...80...90...100 - done.
GDAL: GDALClose(out.tif, this=0x2067ca0)
GDAL: GDALClose(, this=0x204ce10)
GDAL: GDALClose(1.jp2, this=0x204dc00)
GDAL: GDALDeregister_GTiff() called.

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

_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to