Skip to main content

How to track down cause of jpeg2000 OutOfMemory error

28 replies [Last post]
johnpoole
Offline
Joined: 2008-03-28

I'm trying to read a small (500 by 500) section from a large jpeg2000 image. It throws an out of memory error. Am I correct in understanding that this can happen from either
the native libraries not being used or the image not being tiled properly?
How do I check those two factors?

code:

BufferedImage bimage = null;
File imageFile = new File(filename);
try {
Iterator readers = ImageIO.getImageReadersByFormatName("jpeg2000");
ImageReader imageReader = (ImageReader)readers.next();
ImageInputStream imageInputStream = ImageIO.createImageInputStream(imageFile);
imageReader.setInput(imageInputStream, true);
ImageReadParam imageReadParam = imageReader.getDefaultReadParam();
int imageIndex = 0;
Rectangle rectangle = new Rectangle((int)rect.getMinX(), (int)rect.getMinY(),
(int)rect.getWidth(), (int)rect.getHeight());
imageReadParam.setSourceRegion(rectangle);
bimage = imageReader.read(imageIndex, imageReadParam);
}
catch (IOException e) {
e.printStackTrace();
}
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at jj2000.j2k.image.DataBlkInt.(DataBlkInt.java:97)
at jj2000.j2k.wavelet.synthesis.InvWTFull.getInternCompData(InvWTFull.java:277)
at jj2000.j2k.image.ImgDataConverter.getData(ImgDataConverter.java:249)
at jj2000.j2k.image.ImgDataConverter.getInternCompData(ImgDataConverter.java:205)
at jj2000.j2k.image.invcomptransf.InvCompTransf.invRCT(InvCompTransf.java:428)
at jj2000.j2k.image.invcomptransf.InvCompTransf.getInternCompData(InvCompTransf.java:362)
at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.readSubsampledRaster(J2KReadState.java:831)
at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.readBufferedImage(J2KReadState.java:384)
at com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReader.read(J2KImageReader.java:454)

Message was edited by: johnpoole

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Daniele Romagnoli

Hi John,
the imageio-ext-kakadujp2 module you are talking about lives within the
imageio-ext project. Therefore, I suggest to continue the discussion to
dev[AT]imageio-ext.dev.java.net mailing list.

Are JAI and Imageio properly installed?
Is the kakadujp2.jar the imageio-ext-kakadujp2 module?

Let me know.
Cheers,
Daniele

On Tue, Jun 24, 2008 at 7:30 PM, wrote:

> Brian,
>
> I'm trying to the imageio-ext-kakadujp2 code working on Linux.
>
> This code works on windows, but not on linux:
>
> -------------------------------------------------------------------------------
> /usr/java/jre1.6.0_06/bin/java -classpath
> .:./kakadujp2.jar:./imageio-ext-kakadujni-1.0-SNAPSHOT.jar:./imageio-ext-customstreams-1.0-SNAPSHOT.jar:./imag
> eio-ext-imagereadmt-1.0-SNAPSHOT.jar KduTest
>
> --------------------------------------------------------------------------------
> import
> it.geosolutions.imageio.imageioimpl.imagereadmt.ImageReadDescriptorMT;
> import it.geosolutions.imageio.plugins.jp2k.JP2KakaduImageReadParam;
>
> import java.awt.Dimension;
> import java.awt.Rectangle;
> import java.awt.RenderingHints;
> import java.io.File;
> import java.io.IOException;
>
> import javax.imageio.ImageIO;
> import javax.imageio.ImageReadParam;
> import javax.media.jai.ImageLayout;
> import javax.media.jai.JAI;
> import javax.media.jai.ParameterBlockJAI;
> import javax.media.jai.RenderedOp;
>
> public class KduTest{
> public static void main(String args[]){
>
> KduTest.getImage("/data/2007/nwg/utm11_40cm/AB_07_N040_11N_680E_5655N.jp2",new
> Rectangle(9655,0,2844,2666), new Dimension(21,22));
> }
>
> static public void getImage(String filename, Rectangle rect, Dimension
> pixels){
> final File file = new File( filename);
> ImageReadDescriptorMT.register(JAI.getDefaultInstance());
>
> final ParameterBlockJAI pbjImageRead = new ParameterBlockJAI(
> "ImageReadMT");
> ImageLayout l = new ImageLayout();
>
> l.setTileHeight(512);
> l.setTileWidth(512);
>
> ImageReadParam param = new JP2KakaduImageReadParam();
> param.setSourceRegion(rect);
> param.setSourceSubsampling((int)(rect.width/pixels.width),
> (int)(rect.height/pixels.height),
> 0, 0);
> pbjImageRead.setParameter("ReadParam",param);
> pbjImageRead.setParameter("Input", file);
> RenderedOp image = JAI.create("ImageReadMT", pbjImageRead,
> new RenderingHints(JAI.KEY_IMAGE_LAYOUT, l));
> try {
> ImageIO.write(image, "JPEG", new File("debug.JPG"));
> } catch (IOException e) {
> e.printStackTrace();
> }
> }
> }
>
> Gives:
> Error: One factory fails for the operation "ImageReadMT"
> Occurs in: javax.media.jai.ThreadSafeOperationRegistry
> java.lang.reflect.InvocationTargetException
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at javax.media.jai.FactoryCache.invoke(FactoryCache.java:122)
> at
> javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1674)
> at
> javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeOperationRegistry.java:473)
> at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:332)
> at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:819)
> at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:867)
> at javax.media.jai.RenderedOp.getColorModel(RenderedOp.java:2242)
> at javax.imageio.ImageTypeSpecifier.(Unknown Source)
> at javax.imageio.ImageTypeSpecifier.createFromRenderedImage(Unknown
> Source)
> at javax.imageio.ImageIO.write(Unknown Source)
> at javax.imageio.ImageIO.write(Unknown Source)
> at KduTest.getImage(KduTest.java:45)
> at KduTest.main(KduTest.java:19)
> Caused by: java.lang.RuntimeException: java.lang.RuntimeException: An
> uncaught runtime exception has occurred
> at
> it.geosolutions.imageio.imageioimpl.imagereadmt.ImageReadMTCRIF.create(ImageReadMTCRIF.java:332)
> ... 17 more
> Caused by: java.lang.RuntimeException: An uncaught runtime exception has
> occurred
> at
> com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.initializeRead(J2KReadState.java:708)
> at
> com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.(J2KReadState.java:209)
> at
> com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReader.readHeader(J2KImageReader.java:381)
> at
> com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReader.getImageTypes(J2KImageReader.java:397)
> at javax.imageio.ImageReader.getRawImageType(Unknown Source)
> at
> it.geosolutions.imageio.imageioimpl.imagereadmt.ImageReadOpImageMT.layoutHelper(ImageReadOpImageMT.java:221)
> at
> it.geosolutions.imageio.imageioimpl.imagereadmt.ImageReadOpImageMT.(ImageReadOpImageMT.java:444)
> at
> it.geosolutions.imageio.imageioimpl.imagereadmt.ImageReadMTCRIF.create(ImageReadMTCRIF.java:329)
> ... 17 more
> Caused by: java.io.IOException: File too long.
> at
> jj2000.j2k.fileformat.reader.FileFormatReader.readFileFormat(FileFormatReader.java:207)
> at
> com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.initializeRead(J2KReadState.java:418)
> ... 24 more
> [Message sent by forum member 'johnvaltus' (johnvaltus)]
>
> http://forums.java.net/jive/thread.jspa?messageID=282299
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>
>

--
-------------------------------------------------------
Eng. Daniele Romagnoli
Software Engineer

GeoSolutions S.A.S.
Via Carignoni 51
55041 Camaiore (LU)
Italy

phone: +39 0584983027
fax: +39 0584983027
mob: +39 328 0559267

http://www.geo-solutions.it

-------------------------------------------------------
[att1.html]

johnpoole
Offline
Joined: 2008-03-28

Are you "simboss" on there? I don't use IRC much.

I loaded the project into eclipse on my laptop and it worked properly. I may have had a slightly older version of eclipse on the other PC.

All I really need to do is use the plugin to do an imageio.read of a jpeg2000 with an ROI.

Will the kakadu dll/so and the jar from imageio-ext-kakadujp2 be all I need?

Simone Giannecchini

Sorry,
I misread your email. My message was referred to your "tomorrow" part :-)

I am onlin now and I will be in the next 4-6 hours.

Simone.

On Thu, May 22, 2008 at 10:13 PM, wrote:
> Are you "simboss" on there? I don't use IRC much.
>
> I loaded the project into eclipse on my laptop and it worked properly. I may have had a slightly older version of eclipse on the other PC.
>
> All I really need to do is use the plugin to do an imageio.read of a jpeg2000 with an ROI.
>
> Will the kakadu dll/so and the jar from imageio-ext-kakadujp2 be all I need?
> [Message sent by forum member 'johnpoole' (johnpoole)]
>
> http://forums.java.net/jive/thread.jspa?messageID=276113
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>
>

--
-------------------------------------------------------
Eng. Simone Giannecchini
President /CEO GeoSolutions S.A.S.
Via Carignoni 51
55041 Camaiore (LU)
Italy

phone: +39 0584983027
fax: +39 0584983027
mob: +39 333 8128928

http://www.geo-solutions.it

-------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

johnvaltus
Offline
Joined: 2006-03-31

I'm getting an error from this code:
Error: One factory fails for the operation "ImageReadMT"

public PlanarImage getImageExt(String filename, Envelope rect, float scalex, float scaley){
Rectangle region = new Rectangle((int)rect.getMinX(), (int)rect.getMinY(),
(int)rect.getWidth(), (int)rect.getHeight());

final File file = new File( filename);
ImageReadDescriptorMT.register(JAI.getDefaultInstance());

final ParameterBlockJAI pbjImageRead = new ParameterBlockJAI(
"ImageReadMT");
ImageLayout l = new ImageLayout();

l.setTileHeight(512);
l.setTileWidth(512);

ImageReadParam param = new JP2KakaduImageReadParam();
param.setSourceRegion(region);

param.setSourceSubsampling((int)(1f/scalex), (int)(1f/scaley),
0, 0);
pbjImageRead.setParameter("ReadParam",param);
pbjImageRead.setParameter("Input", file);
RenderedOp image = JAI.create("ImageReadMT", pbjImageRead,
new RenderingHints(JAI.KEY_IMAGE_LAYOUT, l));

return image;
}
I'm going to check the installation of JAI, and Imageio

But just in case someone else gets the same error, I'll have info posted here.

bpb
Offline
Joined: 2004-06-23

That is because the operation name is "ImageRead"

Brian

> I'm getting an error from this code:
> Error: One factory fails for the operation
> "ImageReadMT"
>
>
> public PlanarImage getImageExt(String filename,
> Envelope rect, float scalex, float scaley){
> Rectangle region = new
> Rectangle((int)rect.getMinX(), (int)rect.getMinY(),
> (int)rect.getWidth(), (int)rect.getHeight());
> final File file = new File( filename);
> ImageReadDescriptorMT.register(JAI.getDefaultInstance
> ());
>
> final ParameterBlockJAI pbjImageRead = new
> w ParameterBlockJAI(
> "ImageReadMT");
> ImageLayout l = new ImageLayout();
>
> l.setTileHeight(512);
> l.setTileWidth(512);
>
> ImageReadParam param = new
> w JP2KakaduImageReadParam();
> param.setSourceRegion(region);
>
> param.setSourceSubsampling((int)(1f/scalex),
> , (int)(1f/scaley),
> 0, 0);
> pbjImageRead.setParameter("ReadParam",param);
> pbjImageRead.setParameter("Input", file);
> RenderedOp image = JAI.create("ImageReadMT",
> , pbjImageRead,
> new RenderingHints(JAI.KEY_IMAGE_LAYOUT, l));
>
> return image;
> }
> I'm going to check the installation of JAI, and
> Imageio
>
> But just in case someone else gets the same error,
> I'll have info posted here.

johnvaltus
Offline
Joined: 2006-03-31

Brian,

I'm trying to the imageio-ext-kakadujp2 code working on Linux.

This code works on windows, but not on linux:
-------------------------------------------------------------------------------
/usr/java/jre1.6.0_06/bin/java -classpath .:./kakadujp2.jar:./imageio-ext-kakadujni-1.0-SNAPSHOT.jar:./imageio-ext-customstreams-1.0-SNAPSHOT.jar:./imag
eio-ext-imagereadmt-1.0-SNAPSHOT.jar KduTest
--------------------------------------------------------------------------------
import it.geosolutions.imageio.imageioimpl.imagereadmt.ImageReadDescriptorMT;
import it.geosolutions.imageio.plugins.jp2k.JP2KakaduImageReadParam;

import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.imageio.ImageReadParam;
import javax.media.jai.ImageLayout;
import javax.media.jai.JAI;
import javax.media.jai.ParameterBlockJAI;
import javax.media.jai.RenderedOp;

public class KduTest{
public static void main(String args[]){
KduTest.getImage("/data/2007/nwg/utm11_40cm/AB_07_N040_11N_680E_5655N.jp2",new Rectangle(9655,0,2844,2666), new Dimension(21,22));
}

static public void getImage(String filename, Rectangle rect, Dimension pixels){
final File file = new File( filename);
ImageReadDescriptorMT.register(JAI.getDefaultInstance());

final ParameterBlockJAI pbjImageRead = new ParameterBlockJAI(
"ImageReadMT");
ImageLayout l = new ImageLayout();

l.setTileHeight(512);
l.setTileWidth(512);

ImageReadParam param = new JP2KakaduImageReadParam();
param.setSourceRegion(rect);
param.setSourceSubsampling((int)(rect.width/pixels.width), (int)(rect.height/pixels.height),
0, 0);
pbjImageRead.setParameter("ReadParam",param);
pbjImageRead.setParameter("Input", file);
RenderedOp image = JAI.create("ImageReadMT", pbjImageRead,
new RenderingHints(JAI.KEY_IMAGE_LAYOUT, l));
try {
ImageIO.write(image, "JPEG", new File("debug.JPG"));
} catch (IOException e) {
e.printStackTrace();
}
}
}

Gives:
Error: One factory fails for the operation "ImageReadMT"
Occurs in: javax.media.jai.ThreadSafeOperationRegistry
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at javax.media.jai.FactoryCache.invoke(FactoryCache.java:122)
at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1674)
at javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeOperationRegistry.java:473)
at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:332)
at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:819)
at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:867)
at javax.media.jai.RenderedOp.getColorModel(RenderedOp.java:2242)
at javax.imageio.ImageTypeSpecifier.(Unknown Source)
at javax.imageio.ImageTypeSpecifier.createFromRenderedImage(Unknown Source)
at javax.imageio.ImageIO.write(Unknown Source)
at javax.imageio.ImageIO.write(Unknown Source)
at KduTest.getImage(KduTest.java:45)
at KduTest.main(KduTest.java:19)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: An uncaught runtime exception has occurred
at it.geosolutions.imageio.imageioimpl.imagereadmt.ImageReadMTCRIF.create(ImageReadMTCRIF.java:332)
... 17 more
Caused by: java.lang.RuntimeException: An uncaught runtime exception has occurred
at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.initializeRead(J2KReadState.java:708)
at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.(J2KReadState.java:209)
at com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReader.readHeader(J2KImageReader.java:381)
at com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReader.getImageTypes(J2KImageReader.java:397)
at javax.imageio.ImageReader.getRawImageType(Unknown Source)
at it.geosolutions.imageio.imageioimpl.imagereadmt.ImageReadOpImageMT.layoutHelper(ImageReadOpImageMT.java:221)
at it.geosolutions.imageio.imageioimpl.imagereadmt.ImageReadOpImageMT.(ImageReadOpImageMT.java:444)
at it.geosolutions.imageio.imageioimpl.imagereadmt.ImageReadMTCRIF.create(ImageReadMTCRIF.java:329)
... 17 more
Caused by: java.io.IOException: File too long.
at jj2000.j2k.fileformat.reader.FileFormatReader.readFileFormat(FileFormatReader.java:207)
at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.initializeRead(J2KReadState.java:418)
... 24 more

Jeffrey Kesselman

Use a profiler and profile your memory usage.

Netbeans comes with one.

JK

jai-imageio@javadesktop.org wrote:
> Brian,
>
> I'm trying to the imageio-ext-kakadujp2 code working on Linux.
>
> This code works on windows, but not on linux:
> -------------------------------------------------------------------------------
> /usr/java/jre1.6.0_06/bin/java -classpath .:./kakadujp2.jar:./imageio-ext-kakadujni-1.0-SNAPSHOT.jar:./imageio-ext-customstreams-1.0-SNAPSHOT.jar:./imag
> eio-ext-imagereadmt-1.0-SNAPSHOT.jar KduTest
> --------------------------------------------------------------------------------
> import it.geosolutions.imageio.imageioimpl.imagereadmt.ImageReadDescriptorMT;
> import it.geosolutions.imageio.plugins.jp2k.JP2KakaduImageReadParam;
>
> import java.awt.Dimension;
> import java.awt.Rectangle;
> import java.awt.RenderingHints;
> import java.io.File;
> import java.io.IOException;
>
> import javax.imageio.ImageIO;
> import javax.imageio.ImageReadParam;
> import javax.media.jai.ImageLayout;
> import javax.media.jai.JAI;
> import javax.media.jai.ParameterBlockJAI;
> import javax.media.jai.RenderedOp;
>
> public class KduTest{
> public static void main(String args[]){
> KduTest.getImage("/data/2007/nwg/utm11_40cm/AB_07_N040_11N_680E_5655N.jp2",new Rectangle(9655,0,2844,2666), new Dimension(21,22));
> }
>
> static public void getImage(String filename, Rectangle rect, Dimension pixels){
> final File file = new File( filename);
> ImageReadDescriptorMT.register(JAI.getDefaultInstance());
>
> final ParameterBlockJAI pbjImageRead = new ParameterBlockJAI(
> "ImageReadMT");
> ImageLayout l = new ImageLayout();
>
> l.setTileHeight(512);
> l.setTileWidth(512);
>
> ImageReadParam param = new JP2KakaduImageReadParam();
> param.setSourceRegion(rect);
> param.setSourceSubsampling((int)(rect.width/pixels.width), (int)(rect.height/pixels.height),
> 0, 0);
> pbjImageRead.setParameter("ReadParam",param);
> pbjImageRead.setParameter("Input", file);
> RenderedOp image = JAI.create("ImageReadMT", pbjImageRead,
> new RenderingHints(JAI.KEY_IMAGE_LAYOUT, l));
> try {
> ImageIO.write(image, "JPEG", new File("debug.JPG"));
> } catch (IOException e) {
> e.printStackTrace();
> }
> }
> }
>
> Gives:
> Error: One factory fails for the operation "ImageReadMT"
> Occurs in: javax.media.jai.ThreadSafeOperationRegistry
> java.lang.reflect.InvocationTargetException
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at javax.media.jai.FactoryCache.invoke(FactoryCache.java:122)
> at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1674)
> at javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeOperationRegistry.java:473)
> at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:332)
> at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:819)
> at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:867)
> at javax.media.jai.RenderedOp.getColorModel(RenderedOp.java:2242)
> at javax.imageio.ImageTypeSpecifier.(Unknown Source)
> at javax.imageio.ImageTypeSpecifier.createFromRenderedImage(Unknown Source)
> at javax.imageio.ImageIO.write(Unknown Source)
> at javax.imageio.ImageIO.write(Unknown Source)
> at KduTest.getImage(KduTest.java:45)
> at KduTest.main(KduTest.java:19)
> Caused by: java.lang.RuntimeException: java.lang.RuntimeException: An uncaught runtime exception has occurred
> at it.geosolutions.imageio.imageioimpl.imagereadmt.ImageReadMTCRIF.create(ImageReadMTCRIF.java:332)
> ... 17 more
> Caused by: java.lang.RuntimeException: An uncaught runtime exception has occurred
> at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.initializeRead(J2KReadState.java:708)
> at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.(J2KReadState.java:209)
> at com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReader.readHeader(J2KImageReader.java:381)
> at com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReader.getImageTypes(J2KImageReader.java:397)
> at javax.imageio.ImageReader.getRawImageType(Unknown Source)
> at it.geosolutions.imageio.imageioimpl.imagereadmt.ImageReadOpImageMT.layoutHelper(ImageReadOpImageMT.java:221)
> at it.geosolutions.imageio.imageioimpl.imagereadmt.ImageReadOpImageMT.(ImageReadOpImageMT.java:444)
> at it.geosolutions.imageio.imageioimpl.imagereadmt.ImageReadMTCRIF.create(ImageReadMTCRIF.java:329)
> ... 17 more
> Caused by: java.io.IOException: File too long.
> at jj2000.j2k.fileformat.reader.FileFormatReader.readFileFormat(FileFormatReader.java:207)
> at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.initializeRead(J2KReadState.java:418)
> ... 24 more
> [Message sent by forum member 'johnvaltus' (johnvaltus)]
>
> http://forums.java.net/jive/thread.jspa?messageID=282299
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

datagazetteer
Offline
Joined: 2006-10-17

> What I can tell you is that the imageio-ext project
> imageio-ext.dev.java.net seems to have a Kakadu-based
> ImageIO
> plugin. I think you should take a look at that, as
> Kakadu
> is pretty much the gold standard for processing
> JPEG2000.

The JNI supplied with the Kakadu software does not appear to be thread-safe. Do you know if the imageio-ext implementation works around that?

Simone Giannecchini

Hi,
I am one of the guys behind imageio-ext.
There are various plugins that can be used to access jpeg2000 images
inside that project.
Specifically talking about kakadu, there is an experimental plugin
which we have used for some jpeg2000 images which is based directly on
the kakadu JNI bindings.
It does support multithreded tile access, I have specifically
implemented a new JAI operation called ImageReadMT which is able to
pull tiles from a single codestream in a JP2 file in parallel.
I am right now working on it to add box parsing capabilities to decode
GeoJp2 and GML-in-JP2 hence I would be curios about feedback for it.

Side not, kakadu is not free or open source but Imageio-ext is LGPL
hence you can play around with it without licensing problems, in case
you already have a kakadu license.

Ciao,
Simone.

On Wed, Apr 16, 2008 at 3:52 PM, wrote:
> > What I can tell you is that the imageio-ext project
> > imageio-ext.dev.java.net seems to have a Kakadu-based
> > ImageIO
> > plugin. I think you should take a look at that, as
> > Kakadu
> > is pretty much the gold standard for processing
> > JPEG2000.
>
> The JNI supplied with the Kakadu software does not appear to be thread-safe. Do you know if the imageio-ext implementation works around that?
> [Message sent by forum member 'datagazetteer' (datagazetteer)]
>
> http://forums.java.net/jive/thread.jspa?messageID=269477
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>
>

--
-------------------------------------------------------
Eng. Simone Giannecchini
President /CEO GeoSolutions S.A.S.
Via Carignoni 51
55041 Camaiore (LU)
Italy

phone: +39 0584983027
fax: +39 0584983027
mob: +39 333 8128928

http://www.geo-solutions.it

-------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

datagazetteer
Offline
Joined: 2006-10-17

Simone --

Is your experimental binding to Kakadu available somewhere? I have a Kakadu license and the project I'm working on would greatly benefit from being able to pull multiple tiles from a single codestream at the same time. I'm using J2K for straight image access and processing (not the geospatial extensions), but I'd be willing to offer feedback on the experimental Kakadu binding stuff...

Thanks in advance,

Peter

Simone Giannecchini

Ciao Peter,

-- the imageio-ext project is here https://imageio-ext.dev.java.net/
we do not have an official release yet hence you need to grab the
source code
-- the code can be accessed through the subversion repo here
https://imageio-ext.dev.java.net/source/browse/imageio-ext/ (you need
the java.net login)
-- user guide https://imageio-ext.dev.java.net/svn/imageio-ext/trunk/documentation/Ima...
set up guide
https://imageio-ext.dev.java.net/svn/imageio-ext/trunk/documentation/Ima...

If you are willing to spend a few hours playing with the project we'll
guide you through all the steps since I am pretty interested in how we
can improve the end user (which is a developer for us :-) experience.

Ciao,
Simone.

On Wed, Apr 16, 2008 at 11:18 PM, wrote:
> Simone --
>
> Is your experimental binding to Kakadu available somewhere? I have a Kakadu license and the project I'm working on would greatly benefit from being able to pull multiple tiles from a single codestream at the same time. I'm using J2K for straight image access and processing (not the geospatial extensions), but I'd be willing to offer feedback on the experimental Kakadu binding stuff...
>
> Thanks in advance,
>
>
> Peter
> [Message sent by forum member 'datagazetteer' (datagazetteer)]
>
> http://forums.java.net/jive/thread.jspa?messageID=269580
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>
>

--
-------------------------------------------------------
Eng. Simone Giannecchini
President /CEO GeoSolutions S.A.S.
Via Carignoni 51
55041 Camaiore (LU)
Italy

phone: +39 0584983027
fax: +39 0584983027
mob: +39 333 8128928

http://www.geo-solutions.it

-------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

johnvaltus
Offline
Joined: 2006-03-31

Simone, Some of the install/setup instructions aren't that clear. Where can I got to ask about some details?
In particular:
Can I use kakadu 5.2.4 or do I need 5.2.6?

Section 3.7.2.1 kakdu Config mentions obj files that have to be moved, but not to where.

The build fails when it can't find jp_local.h. I can add it to the includes list, but I'd rather start with a clean build before I start guessing at how to set things up.

John

Daniele Romagnoli

Hi John,
5.2.4 version should be ok.
Section 3.7.1.1 contains a table specifying "File-Originating Location"
which states where to find obj files which should be placed
onkakaduVERSION\apps\make.
(This is needed only if you wish to use our GDAL patched version).

Anyway, I missed previous discussion. Could you repeat me your needs and
what are you doing so I can help you better?
Regards,

Daniele

PS: Note that we are slightly refactoring the guides.

On Tue, May 20, 2008 at 9:02 PM, wrote:

> Simone, Some of the install/setup instructions aren't that clear. Where can
> I got to ask about some details?
> In particular:
> Can I use kakadu 5.2.4 or do I need 5.2.6?
>
> Section 3.7.2.1 kakdu Config mentions obj files that have to be moved, but
> not to where.
>
> The build fails when it can't find jp_local.h. I can add it to the includes
> list, but I'd rather start with a clean build before I start guessing at how
> to set things up.
>
> John
> [Message sent by forum member 'johnvaltus' (johnvaltus)]
>
> http://forums.java.net/jive/thread.jspa?messageID=275558
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>
>

--
-------------------------------------------------------
Eng. Daniele Romagnoli
Software Engineer

GeoSolutions S.A.S.
Via Carignoni 51
55041 Camaiore (LU)
Italy

phone: +39 0584983027
fax: +39 0584983027
mob: +39 328 0559267

http://www.geo-solutions.it

-------------------------------------------------------
[att1.html]

johnvaltus
Offline
Joined: 2006-03-31

Daniele, thanks for the reply. We use the jpeg2000 format to compress geospatial imagery. I'm using the jni libraries that come with the kakadu software, but being able to use imageio calls would be preferable.
So, what I need is a way to access the JPEG2000 data through imageio calls. As far as I can tell, the kakadu libs are the only ones that work fast enough and on large enough files. I'm developing on windows, but all our servers run on linux.

I will try recompiling with the obj files in kakadu\versions\apps\make. Should jp_local.h be accessible if I've set it up correctly?

Daniele Romagnoli

Hi John,

let me give you some (I hope helpful :-) ) notes:
- The instructions you found in the SetupGuide of our ImageIO-Ext projects
allows to build Kakadu as well as GDAL with support for Kakadu. The "obj
files" management we have talked about is only needed in case you need to
build GDAL with support for Kakadu. (If you dont need GDAL, you can avoid
the "obj" sections... In the next version of the guide we will split
instructions in two sections)
- ImageIO-Ext project (available at: https://imageio-ext.dev.java.net/)
contains two ImageIO plugins developed on kakadu: a first one
[imageio-ext-gdalkakadujp2] leveraging on GDAL (with support for Kakadu), a
second one [imageio-ext-kakadujp2] leveraging directly on the Kakadu library
. (Note that we are working on an improved version of imageio-ext-kakadujp2
with add for multiple codestreams/jp2boxes/stripe_decompressor support)
You can take a look on these imageio plugins.

Anyway, if your actual need it's only building kakadu and the related Java
bindings, you should simply do the following steps:
1st) build the coresys project/solution
2nd) build the apps project/solution (which contains Kdu_hyperdoc which
generates java bindings)
3rd) build the managed project/solution (which generates kdu_jni)

Let me know if you need more info.

Best regards,
Daniele

On Wed, May 21, 2008 at 5:30 PM, wrote:

> Daniele, thanks for the reply. We use the jpeg2000 format to compress
> geospatial imagery. I'm using the jni libraries that come with the kakadu
> software, but being able to use imageio calls would be preferable.
> So, what I need is a way to access the JPEG2000 data through imageio calls.
> As far as I can tell, the kakadu libs are the only ones that work fast
> enough and on large enough files. I'm developing on windows, but all our
> servers run on linux.
>
> I will try recompiling with the obj files in kakadu\versions\apps\make.
> Should jp_local.h be accessible if I've set it up correctly?
> [Message sent by forum member 'johnvaltus' (johnvaltus)]
>
> http://forums.java.net/jive/thread.jspa?messageID=275745
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>
>

--
-------------------------------------------------------
Eng. Daniele Romagnoli
Software Engineer

GeoSolutions S.A.S.
Via Carignoni 51
55041 Camaiore (LU)
Italy

phone: +39 0584983027
fax: +39 0584983027
mob: +39 328 0559267

http://www.geo-solutions.it

-------------------------------------------------------
[att1.html]

johnvaltus
Offline
Joined: 2006-03-31

Ok that makes sense and is a lot simpler. I already went through those steps to use my own java code, so I assume I can just the imageio-ext jars as long as the kdu_jni classes are on the path?
I will try it and report back.

johnvaltus
Offline
Joined: 2006-03-31

So, I'm not building any of the GDAL code, but I do still need to build the jar for the kakadu code, right?

I'm getting this error, the dir is there, but the jar is not.
Project 'imageio-ext-kakadujp2' is missing required library: 'C:\Documents and Settings\john\.m2\repository\it\geosolutions\imageio-ext\imageio-ext-kakadujni\1.0-SNAPSHOT\imageio-ext-kakadujni-1.0-SNAPSHOT.jar' imageio-ext-kakadujp2 Build path 1211398815695 194336

Or does the svn repository contain jar files that I can just use without and compilation?

Thanks for your help,
John

Simone Giannecchini

Ciao John,
can you hop on the IRC geotools channel,
(irc://irc.freenode.org/geotools) so that I can try and help you out
here?

Simone.

--
-------------------------------------------------------
Eng. Simone Giannecchini
President /CEO GeoSolutions S.A.S.
Via Carignoni 51
55041 Camaiore (LU)
Italy

phone: +39 0584983027
fax: +39 0584983027
mob: +39 333 8128928

http://www.geo-solutions.it

-------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

johnpoole
Offline
Joined: 2008-03-28

Sorry Simone, I missed this yesterday. I really would like to get this running. Can you let me know if you're available sometime today or tomorrow?
Thanks,
John

Simone Giannecchini

I should be available all day on both geotools and geosolutions channels.

Simone.

On Thu, May 22, 2008 at 7:10 PM, wrote:
> Sorry Simone, I missed this yesterday. I really would like to get this running. Can you let me know if you're available sometime today or tomorrow?
> Thanks,
> John
> [Message sent by forum member 'johnpoole' (johnpoole)]
>
> http://forums.java.net/jive/thread.jspa?messageID=276066
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>
>

--
-------------------------------------------------------
Eng. Simone Giannecchini
President /CEO GeoSolutions S.A.S.
Via Carignoni 51
55041 Camaiore (LU)
Italy

phone: +39 0584983027
fax: +39 0584983027
mob: +39 333 8128928

http://www.geo-solutions.it

-------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

johnpoole
Offline
Joined: 2008-03-28

great, I'm just going to get set up on this computer. I'm on geotools as "JohnValtus", Thanks

bpb
Offline
Joined: 2004-06-23

The Java implementation of the JPEG2000 reader is based on a decoder which only decodes the entire tile-component at the specified resolution level no matter which area is requested. Therefore if your image is untiled it will try to encode the entire image at the specified resolution.

We have in fact implemented a version of the inverse wavelet transform which decodes only the area requested (plus some context needed by the IWT) but this is not quite ready for prime time.

Brian

> The actual area on the test is:
> rectjava.awt.Rectangle[x=2538,y=5902,width=531,height=
> 530]
>
> but you are saying that if I have the native
> libraries installed properly and the jp2 is tiled I
> would not have this problem, right?
>
> I'm using kakadu right now and it's a major hassle to
> work with
>
> Message was edited by: johnpoole
>
> Message was edited by: johnpoole

haystack
Offline
Joined: 2008-05-15

Brian,

How are you going with the enhancements? - I have some large 50,000x50,000 pixel J2K images that require ridiculous amounts of memory to to extract regions of interest.

HS.

Nidel, Mike

Area you reading the 500x500 block from near the end of the file?
I think the Java-only JPEG2000 reader has issues with using more
memory than needed when reading tiles from the later (lower-right)
part of the file.

> -----Original Message-----
> From: jai-imageio@javadesktop.org
> [mailto:jai-imageio@javadesktop.org]
> Sent: Friday, March 28, 2008 11:56 AM
> To: interest@jai-imageio.dev.java.net
> Subject: [JAI-IMAGEIO] How to track down cause of OutOfMemory error
>
> I'm trying to read a small (500 by 500) section from a large
> jpeg2000 image. It throws an out of memory error. Am I
> correct in understanding that this can happen from either the
> native libraries not being used or the image not being tiled properly?
> How do I check those two factors?
>
> code:
>
> BufferedImage bimage = null;
> File imageFile = new File(filename);
> try {
> Iterator readers =
> ImageIO.getImageReadersByFormatName("jpeg2000");
> ImageReader imageReader =
> (ImageReader)readers.next();
> ImageInputStream imageInputStream =
> ImageIO.createImageInputStream(imageFile);
> imageReader.setInput(imageInputStream, true);
> ImageReadParam imageReadParam =
> imageReader.getDefaultReadParam();
> int imageIndex = 0;
> Rectangle rectangle = new
> Rectangle((int)rect.getMinX(), (int)rect.getMinY(),
> (int)rect.getWidth(),
> (int)rect.getHeight());
> imageReadParam.setSourceRegion(rectangle);
> bimage = imageReader.read(imageIndex,
> imageReadParam);
> }
> catch (IOException e) {
> e.printStackTrace();
> }
> Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
> at jj2000.j2k.image.DataBlkInt.(DataBlkInt.java:97)
> at
> jj2000.j2k.wavelet.synthesis.InvWTFull.getInternCompData(InvWT
> Full.java:277)
> at
> jj2000.j2k.image.ImgDataConverter.getData(ImgDataConverter.java:249)
> at
> jj2000.j2k.image.ImgDataConverter.getInternCompData(ImgDataCon
> verter.java:205)
> at
> jj2000.j2k.image.invcomptransf.InvCompTransf.invRCT(InvCompTra
> nsf.java:428)
> at
> jj2000.j2k.image.invcomptransf.InvCompTransf.getInternCompData
> (InvCompTransf.java:362)
> at
> com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.readSu
> bsampledRaster(J2KReadState.java:831)
> at
> com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.readBu
> fferedImage(J2KReadState.java:384)
> at
> com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReader.read
> (J2KImageReader.java:454)
> [Message sent by forum member 'johnpoole' (johnpoole)]
>
> http://forums.java.net/jive/thread.jspa?messageID=266434
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail:
> interest-help@jai-imageio.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

johnpoole
Offline
Joined: 2008-03-28

The actual area on the test is:
rectjava.awt.Rectangle[x=2538,y=5902,width=531,height=530]

but you are saying that if I have the native libraries installed properly and the jp2 is tiled I would not have this problem, right?

I'm using kakadu right now and it's a major hassle to work with

Message was edited by: johnpoole

Message was edited by: johnpoole

Nidel, Mike

I'm not sure if the native libraries used in the JPEG2000
decoder avoid this problem. I knew the answer at some point
a couple of years ago.

What I can tell you is that the imageio-ext project
imageio-ext.dev.java.net seems to have a Kakadu-based ImageIO
plugin. I think you should take a look at that, as Kakadu
is pretty much the gold standard for processing JPEG2000.

Mike

> -----Original Message-----
> From: jai-imageio@javadesktop.org
> [mailto:jai-imageio@javadesktop.org]
> Sent: Friday, March 28, 2008 4:01 PM
> To: interest@jai-imageio.dev.java.net
> Subject: Re: RE: [JAI-IMAGEIO] How to track down cause of
> OutOfMemory error
>
> The actual is:
> rectjava.awt.Rectangle[x=2538,y=5902,width=531,height=530]
>
> are you saying that even if I have the native libraries
> installed properly and the jp2 is tiled I'd have this problem?
>
> I'm using kakadu right now and it's a major hassle to work
> with [Message sent by forum member 'johnpoole' (johnpoole)]
>
> http://forums.java.net/jive/thread.jspa?messageID=266498
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail:
> interest-help@jai-imageio.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

johnpoole
Offline
Joined: 2008-03-28

Mike & brb,
Thanks for the replies. It looks like the imageio-ext project is my best bet for using JP2K for now. I'll keep a watch on this forum for news of when the official version of JPEG2000 decompression is out.

bpb
Offline
Joined: 2004-06-23

We will post something for sure when code is available. We would definitely be interested in someone else exercising it.

Brian

> Mike & brb,
> Thanks for the replies. It looks like the imageio-ext
> project is my best bet for using JP2K for now. I'll
> keep a watch on this forum for news of when the
> official version of JPEG2000 decompression is out.