Loading jp2 image problem

For discussion of LizardTech's free Decode SDK for MrSID and JPEG 2000.

Moderator: jskiffington

Loading jp2 image problem

Postby BrianP » Fri Jan 15, 2010 10:17 am

I have a jp2 image I am trying to load. I took some code from the sample and I have this (using SDK-7.0.0.2167):

const LTFileSpec fileSpec(_fname.c_str());
J2KImageReader *reader = J2KImageReader::create();
sts = reader->initialize(fileSpec, false);
const LTIScene scene(x, y, w, h, 1.0);
const lt_uint32 siz = w * h * 1;
lt_uint8* membuf = new lt_uint8[siz*3];
void* bufs[3] = { membuf+siz*0, membuf+siz*1, membuf+siz*2 };
LTISceneBuffer bufData(reader->getPixelProps(), w, h, bufs);
sts = reader->read(scene, bufData);

And this crashes. The image is 5000x5000. I have tried x=0,y=0,w=916, w=597 and x=4084,y=4403,w=916,w=597.

I have the same code I used for a MrSid image (identical image, just different format) and it works fine. Only the J2K version is crashing.

I have no idea. I know openJpeg has issues with this same image, but jasper worked fine. Both images view fine in the Windows ExpressView Broswer plugin (not sure what version).

The image is (on disk) 9.7M, so I don't think I can attach the image.

This is what GDB reports:
#0 0x0825d9a3 in kdsd_tile::process ()
#1 0x0825e71d in kdu_stripe_decompressor::pull_common #2 0x08262c1a in kdu_stripe_decompressor::pull_stripe ()
#3 0x080e194f in /c++/4.1.2/bits/stl_iterator.h:649
#4 0x080e30d0 in LizardTech::JPCReader::decodeStrip ()
#5 0x080f3566 in LizardTech::LTIImageStage::readStrip ()
#6 0x080f0a42 in LizardTech::LTIImageFilter::decodeStrip ()
#7 0x080f3566 in LizardTech::LTIImageStage::readStrip ()
#8 0x080f38d2 in LizardTech::LTIImageStage::read ()
#9 0x003049b8 in app::ImageConverterJpeg2000::read

Any thoughts? I thought I was doing something wrong, but when the MrSid decode worked correctly.....

- Brian
BrianP
 
Posts: 10
Joined: Thu Jan 14, 2010 8:27 am

Postby gat » Fri Jan 15, 2010 11:16 am

Is it possible that the jp2 file is not RGB (maybe has an alpha or something)? Can you email us the mrsidinfo output for both the JP2 and SID files? You will find that program in the bin directory of the SDK distro. email it to sdksupport@lizardtech.com.

You can also let LTISceneBuffer allocate its own buffer by simply passing in a NULL to see if that makes a difference.
gat
 
Posts: 28
Joined: Mon Jan 12, 2009 12:41 pm

Postby BrianP » Fri Jan 15, 2010 11:59 am

I just sent the email. Does this mean it is not RGB?

color space: MULTISPECTRAL

- Brian
BrianP
 
Posts: 10
Joined: Thu Jan 14, 2010 8:27 am

Postby BrianP » Fri Jan 15, 2010 2:15 pm

Just to update (since we finished this in email).

The problem was the JP2 was 4 bands rather then 3 like in the mrsid image. Changing my code to let LTISceneBuffer allocate memory for the image and using getWindowBandData() to retrieve the RGB values worked fine.

- Brian
BrianP
 
Posts: 10
Joined: Thu Jan 14, 2010 8:27 am


Return to SDKs

Who is online

Users browsing this forum: No registered users and 1 guest

cron