Skip to main content

[JAI] Jpeg2000 image problem

3 replies [Last post]
Anonymous

Hi,

I am getting java.lang.OutOfMemoryError when I try to open a jp2 with
the code below. The image is not that big (about 2000 x 2000) However,
when I open a bigger jp2 that is saved with a different program like
Photoshop, I can open the image fine. This makes me think that maybe
the code I used to save the jp2 is doing something strange.

Basically,

Saving jp2 with my program -> opens fines in photoshop.
Saving jp2 with photoshop -> opens fines with my program.

Saving jp2 with my program -> OUT_OF_MEMORY_EXCEPTION when open with my
program.
(only happens when I try to open big images, opening small ones are
okay)

Any help is appreciated.

Also, where can I find a list of the J2KImageWriteParam's parameters?
(I don't know what some of the "paraBlock.add(null);" are referring to
below). I looked at the API and the Java Image I/O API Guide, but I'm
still having trouble locating the information.

Thanks,
onyee

------------------------------------------------------------------------
---------------------------------------
// Opening the jp2 image

J2KImageReadParam readParam = new J2KImageReadParam();

ParameterBlock pb = new ParameterBlock();
pb.add(file.getAbsolutePath());
pb.add(new Integer(0));
pb.add(new Boolean(true));
pb.add(new Boolean(true));
pb.add(new Boolean(false));
pb.add(null);
pb.add(null);
pb.add(readParam);
pb.add(null);

src = JAI.create("ImageRead", pb, null);
------------------------------------------------------------------------
--------------------------------------

// saving the jp2 image

J2KImageWriteParam encodeParam = new J2KImageWriteParam();

ParameterBlock paraBlock = new ParameterBlock();
paraBlock.addSource(image);
paraBlock.add(outputFileName);
paraBlock.add("jpeg2000");
paraBlock.add(new Boolean(false));
paraBlock.add(new Boolean(false));
paraBlock.add(new Boolean(false));
paraBlock.add(new Boolean(false));
paraBlock.add(null);
paraBlock.add(null);
paraBlock.add(null);
paraBlock.add(null);
paraBlock.add(null);
paraBlock.add(null);
paraBlock.add(encodeParam);

JAI.create("ImageWrite", paraBlock);
------------------------------------------------------------------------
---------------------------------------------
[att1.html]

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Chan, Onyee-P57131

Brian,

I tried using the "-mx" command to increase the memory, but it didn't
help. It seems like memory is not the problem here. For example, I was
able to open up a large jp2 image (6442 x 5586, 40mb, saved with
photoshop). However, I can't open up a smaller jp2 image (2000 x 2000,
787K, saved with my program). So it seems like there must be something
wrong with the way I'm writing the jp2 image (even though photoshop can
open the jp2 that is generated by my program fine).

Any ideas?

Thanks,
onyee

-----Original Message-----
From: Brian.Burkhalter@Sun.COM [mailto:Brian.Burkhalter@Sun.COM]
Sent: Monday, November 07, 2005 11:21 AM
To: interest@jai.dev.java.net
Subject: Re: [JAI] Jpeg2000 image problem

On Mon, 7 Nov 2005, Chan, Onyee-P57131 wrote:

> I am getting java.lang.OutOfMemoryError when I try to open a jp2 with
> the code below. The image is not that big (about 2000 x 2000)
> However, when I open a bigger jp2 that is saved with a different
> program like Photoshop, I can open the image fine. This makes me
> think that maybe the code I used to save the jp2 is doing something
strange.
>
> Basically,
>
> Saving jp2 with my program -> opens fines in photoshop.
> Saving jp2 with photoshop -> opens fines with my program.
>
> Saving jp2 with my program -> OUT_OF_MEMORY_EXCEPTION when open with
> my program.
> (only happens when I try to open big images, opening small ones are
> okay)
>
> Any help is appreciated.

Use the "-mx" command line option to Java. Look at the "java" tool
documentation here

http://java.sun.com/j2se/1.5.0/docs/tooldocs/index.html#basic

for more information.

> Also, where can I find a list of the J2KImageWriteParam's parameters?
> (I don't know what some of the "paraBlock.add(null);" are referring to

> below). I looked at the API and the Java Image I/O API Guide, but I'm

> still having trouble locating the information.

Latest javadocs are here:

http://java.sun.com/products/java-media/jai/forDevelopers/jai-imageio-1_
1-alpha-docs/index.html

Brian

----------------
Brian Burkhalter
Java Multimedia, Imaging, and Graphics
Sun Microsystems, Inc.

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

Brian Burkhalter

Would you be able to supply the data sets involved? You could e-mail them to
me directly or I could provide an FTP upload site.

Brian

On Mon, 7 Nov 2005, Chan, Onyee-P57131 wrote:

> Brian,
>
> I tried using the "-mx" command to increase the memory, but it didn't
> help. It seems like memory is not the problem here. For example, I was
> able to open up a large jp2 image (6442 x 5586, 40mb, saved with
> photoshop). However, I can't open up a smaller jp2 image (2000 x 2000,
> 787K, saved with my program). So it seems like there must be something
> wrong with the way I'm writing the jp2 image (even though photoshop can
> open the jp2 that is generated by my program fine).
>
> Any ideas?
>
> Thanks,
> onyee
>
>
> -----Original Message-----
> From: Brian.Burkhalter@Sun.COM [mailto:Brian.Burkhalter@Sun.COM]
> Sent: Monday, November 07, 2005 11:21 AM
> To: interest@jai.dev.java.net
> Subject: Re: [JAI] Jpeg2000 image problem
>
> On Mon, 7 Nov 2005, Chan, Onyee-P57131 wrote:
>
>> I am getting java.lang.OutOfMemoryError when I try to open a jp2 with
>> the code below. The image is not that big (about 2000 x 2000)
>> However, when I open a bigger jp2 that is saved with a different
>> program like Photoshop, I can open the image fine. This makes me
>> think that maybe the code I used to save the jp2 is doing something
> strange.
>>
>> Basically,
>>
>> Saving jp2 with my program -> opens fines in photoshop.
>> Saving jp2 with photoshop -> opens fines with my program.
>>
>> Saving jp2 with my program -> OUT_OF_MEMORY_EXCEPTION when open with
>> my program.
>> (only happens when I try to open big images, opening small ones are
>> okay)
>>
>> Any help is appreciated.
>
> Use the "-mx" command line option to Java. Look at the "java" tool
> documentation here
>
> http://java.sun.com/j2se/1.5.0/docs/tooldocs/index.html#basic
>
> for more information.
>
>> Also, where can I find a list of the J2KImageWriteParam's parameters?
>> (I don't know what some of the "paraBlock.add(null);" are referring to
>
>> below). I looked at the API and the Java Image I/O API Guide, but I'm
>
>> still having trouble locating the information.
>
> Latest javadocs are here:
>
> http://java.sun.com/products/java-media/jai/forDevelopers/jai-imageio-1_
> 1-alpha-docs/index.html
>
> Brian
>
> ----------------
> Brian Burkhalter
> Java Multimedia, Imaging, and Graphics
> Sun Microsystems, Inc.
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>

----------------
Brian Burkhalter
Java Multimedia, Imaging, and Graphics
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

Brian Burkhalter

On Mon, 7 Nov 2005, Chan, Onyee-P57131 wrote:

> I am getting java.lang.OutOfMemoryError when I try to open a jp2 with
> the code below. The image is not that big (about 2000 x 2000) However,
> when I open a bigger jp2 that is saved with a different program like
> Photoshop, I can open the image fine. This makes me think that maybe
> the code I used to save the jp2 is doing something strange.
>
> Basically,
>
> Saving jp2 with my program -> opens fines in photoshop.
> Saving jp2 with photoshop -> opens fines with my program.
>
> Saving jp2 with my program -> OUT_OF_MEMORY_EXCEPTION when open with my
> program.
> (only happens when I try to open big images, opening small ones are
> okay)
>
> Any help is appreciated.

Use the "-mx" command line option to Java. Look at the "java" tool
documentation here

http://java.sun.com/j2se/1.5.0/docs/tooldocs/index.html#basic

for more information.

> Also, where can I find a list of the J2KImageWriteParam's parameters?
> (I don't know what some of the "paraBlock.add(null);" are referring to
> below). I looked at the API and the Java Image I/O API Guide, but I'm
> still having trouble locating the information.

Latest javadocs are here:

http://java.sun.com/products/java-media/jai/forDevelopers/jai-imageio-1_...

Brian

----------------
Brian Burkhalter
Java Multimedia, Imaging, and Graphics
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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