Skip to main content

[JAI] Problem reading large J2K images

2 replies [Last post]
Anonymous

Hi,

In my program, I want to be able to read in J2K images and convert it to
a PPM file. Here are some of my code:

------------------------------------------------------------------------
---
if(extension.equals("jp2") || extension.equals("j2k"))
{
J2KImageReadParam readParam = new J2KImageReadParam();

ParameterBlock pb = new ParameterBlock();
pb.add(file.getAbsolutePath());
pb.add(new Integer(0)); // Image
index
pb.add(new Boolean(true)); // Read
META DATA
pb.add(new Boolean(true)); // Read
Thumbnails
pb.add(new Boolean(false)); //
Verify Input
pb.add(null); // Add
Event Listners
pb.add(null); // Locale
pb.add(readParam); // ReadParam
reference
pb.add(null); //
Reader reference

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

.........

// this will create the file
JAI.create("encode", src, stream, "PNM", null);

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

While the above works fine for small J2k images (i.e 916 by 745), it
doesn't work for large j2k images (i.e. 2904 by 520). When I open a
large one, I get the following error:

>Error: One factory fails for the operation "encode"
>Occurs in: javax.media.jai.TreadSafeOperationRegistry...

Any help is appreciated. Thanks.

onyee

[att1.html]

Reply viewing options

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

Here's the stack trace:

Error: One factory fails for the operation "encode"
Occurs in: javax.media.jai.ThreadSafeOperationRegistry
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at javax.media.jai.FactoryCache.invoke(FactoryCache.java:130)
at
javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.jav
a:1682)
at
javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeO
perationRegistry.java:481)
at
javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:340)
at
javax.media.jai.RenderedOp.createInstance(RenderedOp.java:830)
at
javax.media.jai.RenderedOp.createRendering(RenderedOp.java:878)
at javax.media.jai.RenderedOp.getRendering(RenderedOp.java:899)
at javax.media.jai.JAI.createNS(JAI.java:1103)
at javax.media.jai.JAI.create(JAI.java:977)
at javax.media.jai.JAI.create(JAI.java:1672)
at com.gd.sf.MainFrame.createImage(MainFrame.java:2670)
at com.gd.sf.MainFrame.openImage(MainFrame.java:2593)
at com.gd.sf.MainFrame.openImage(MainFrame.java:2449)
at com.gd.sf.MainFrame.access$800(MainFrame.java:54)
at
com.gd.sf.MainFrame$EventActionListener.actionPerformed(MainFrame.jav
a:1378)
at
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:18
49)
at
javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.jav
a:2169)
at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:420)
at
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258
)
at javax.swing.AbstractButton.doClick(AbstractButton.java:302)
at javax.swing.AbstractButton.doClick(AbstractButton.java:282)
at
javax.swing.plaf.basic.BasicMenuItemUI$Actions.actionPerformed(BasicM
enuItemUI.java:969)
at
javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1571)
at
javax.swing.JComponent.processKeyBinding(JComponent.java:2763)
at
javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(JMenuBar.jav
a:656)
at
javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(JMenuBar.jav
a:664)
at
javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(JMenuBar.jav
a:664)
at javax.swing.JMenuBar.processKeyBinding(JMenuBar.java:640)
at
javax.swing.KeyboardManager.fireBinding(KeyboardManager.java:255)
at
javax.swing.KeyboardManager.fireKeyboardAction(KeyboardManager.java:2
42)
at
javax.swing.JComponent.processKeyBindingsForAllComponents(JComponent.
java:2840)
at
javax.swing.JComponent.processKeyBindings(JComponent.java:2832)
at javax.swing.JComponent.processKeyEvent(JComponent.java:2726)
at java.awt.Component.processEvent(Component.java:5265)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at
java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.ja
va:1810)
at
java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboard
FocusManager.java:672)
at
java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeybo
ardFocusManager.java:920)
at
java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeybo
ardFocusManager.java:798)
at
java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFoc
usManager.java:636)
at java.awt.Component.dispatchEventImpl(Component.java:3841)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Window.dispatchEventImpl(Window.java:1774)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:242)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:163)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)

at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)

at
java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Caused by: java.lang.IllegalArgumentException: The destination or source
region
is empty.
at
com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReader.computeRegi
onsWrapper(J2KImageReader.java:180)
at
com.sun.media.imageioimpl.plugins.jpeg2000.J2KRenderedImageCodecLib.<
init>(J2KRenderedImageCodecLib.java:167)
at
com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReaderCodecLib.rea
d(J2KImageReaderCodecLib.java:290)
at
com.sun.media.jai.imageioimpl.ImageReadOpImage.computeTile(ImageReadO
pImage.java:667)
at
com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler
.java:912)
at javax.media.jai.OpImage.getTile(OpImage.java:1139)
at javax.media.jai.PlanarImage.cobbleByte(PlanarImage.java:2863)
at javax.media.jai.PlanarImage.getData(PlanarImage.java:2182)
at
com.sun.media.jai.codecimpl.PNMImageEncoder.encode(PNMImageEncoder.ja
va:284)
at com.sun.media.jai.opimage.EncodeRIF.create(EncodeRIF.java:79)
... 57 more
javax.media.jai.util.ImagingException: All factories fail for the
operation "enc
ode"
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.gd.sf.MainFrame.insertImageNodeInto(MainFrame.java:3022)
at com.gd.sf.MainFrame.openImage(MainFrame.java:2653)
at com.gd.sf.MainFrame.openImage(MainFrame.java:2449)
at com.gd.sf.MainFrame.access$800(MainFrame.java:54)
at
com.gd.sf.MainFrame$EventActionListener.actionPerformed(MainFrame.jav
a:1378)
at
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:18
49)
at
javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.jav
a:2169)
at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:420)
at
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258
)
at javax.swing.AbstractButton.doClick(AbstractButton.java:302)
at javax.swing.AbstractButton.doClick(AbstractButton.java:282)
at
javax.swing.plaf.basic.BasicMenuItemUI$Actions.actionPerformed(BasicM
enuItemUI.java:969)
at
javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1571)
at
javax.swing.JComponent.processKeyBinding(JComponent.java:2763)
at
javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(JMenuBar.jav
a:656)
at
javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(JMenuBar.jav
a:664)
at
javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(JMenuBar.jav
a:664)
at javax.swing.JMenuBar.processKeyBinding(JMenuBar.java:640)
at
javax.swing.KeyboardManager.fireBinding(KeyboardManager.java:255)
at
javax.swing.KeyboardManager.fireKeyboardAction(KeyboardManager.java:2
42)
at
javax.swing.JComponent.processKeyBindingsForAllComponents(JComponent.
java:2840)
at
javax.swing.JComponent.processKeyBindings(JComponent.java:2832)
at javax.swing.JComponent.processKeyEvent(JComponent.java:2726)
at java.awt.Component.processEvent(Component.java:5265)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at
java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.ja
va:1810)
at
java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboard
FocusManager.java:672)
at
java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeybo
ardFocusManager.java:920)
at
java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeybo
ardFocusManager.java:798)
at
java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFoc
usManager.java:636)
at java.awt.Component.dispatchEventImpl(Component.java:3841)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Window.dispatchEventImpl(Window.java:1774)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:242)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:163)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)

at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)

at
java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

Thanks,
onyee

-----Original Message-----
From: Brian.Burkhalter@Sun.COM [mailto:Brian.Burkhalter@Sun.COM]
Sent: Monday, October 24, 2005 12:30 PM
To: interest@jai.dev.java.net
Subject: Re: [JAI] Problem reading large J2K images

What is the rest of the stack trace? Is there an OutOfMemoryException in
there?

Brian

On Mon, 24 Oct 2005, Chan, Onyee-P57131 wrote:

> Hi,
>
> In my program, I want to be able to read in J2K images and convert it
> to a PPM file. Here are some of my code:
>
> ----------------------------------------------------------------------
> --
> ---
> if(extension.equals("jp2") || extension.equals("j2k")) {
> J2KImageReadParam readParam = new J2KImageReadParam();
>
> ParameterBlock pb = new ParameterBlock();
> pb.add(file.getAbsolutePath());
> pb.add(new Integer(0)); // Image
> index
> pb.add(new Boolean(true)); // Read
> META DATA
> pb.add(new Boolean(true)); // Read
> Thumbnails
> pb.add(new Boolean(false)); //
> Verify Input
> pb.add(null); // Add
> Event Listners
> pb.add(null); // Locale
> pb.add(readParam); // ReadParam
> reference
> pb.add(null); //
> Reader reference
>
> src = JAI.create("ImageRead", pb, null); }
>
> .........
>
> // this will create the file
> JAI.create("encode", src, stream, "PNM", null);
>
> ----------------------------------------------------------------------
> --
> ---
>
> While the above works fine for small J2k images (i.e 916 by 745), it
> doesn't work for large j2k images (i.e. 2904 by 520). When I open a
> large one, I get the following error:
>
>> Error: One factory fails for the operation "encode"
>> Occurs in: javax.media.jai.TreadSafeOperationRegistry...
>
> Any help is appreciated. Thanks.
>
>
> onyee
>
>
>
>

----------------
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

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

Brian Burkhalter

What is the rest of the stack trace? Is there an OutOfMemoryException in
there?

Brian

On Mon, 24 Oct 2005, Chan, Onyee-P57131 wrote:

> Hi,
>
> In my program, I want to be able to read in J2K images and convert it to
> a PPM file. Here are some of my code:
>
> ------------------------------------------------------------------------
> ---
> if(extension.equals("jp2") || extension.equals("j2k"))
> {
> J2KImageReadParam readParam = new J2KImageReadParam();
>
> ParameterBlock pb = new ParameterBlock();
> pb.add(file.getAbsolutePath());
> pb.add(new Integer(0)); // Image
> index
> pb.add(new Boolean(true)); // Read
> META DATA
> pb.add(new Boolean(true)); // Read
> Thumbnails
> pb.add(new Boolean(false)); //
> Verify Input
> pb.add(null); // Add
> Event Listners
> pb.add(null); // Locale
> pb.add(readParam); // ReadParam
> reference
> pb.add(null); //
> Reader reference
>
> src = JAI.create("ImageRead", pb, null);
> }
>
> .........
>
> // this will create the file
> JAI.create("encode", src, stream, "PNM", null);
>
> ------------------------------------------------------------------------
> ---
>
> While the above works fine for small J2k images (i.e 916 by 745), it
> doesn't work for large j2k images (i.e. 2904 by 520). When I open a
> large one, I get the following error:
>
>> Error: One factory fails for the operation "encode"
>> Occurs in: javax.media.jai.TreadSafeOperationRegistry...
>
> Any help is appreciated. Thanks.
>
>
> onyee
>
>
>
>

----------------
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