Skip to main content

[JAI] lossless jpeg decompression.

24 replies [Last post]
Anonymous

Hi all,
I am trying to decode the Jpeg compression using JPEGImageDecoder class. I
am sucessfully able to decode the 'Lossy Jpeg Compression'. But for lossless
the same function crashes. this is how i am doing it.
I am using this for decoding Dicom images that are compressed with JPEG.
In this, after the header, the JPEG header and pixels are also encapsulated
in seperate tags.
I've taken the pixels from the encapsulation and made a stream from it, thus
enabling the JPEGImageDecoder class to decode the image.
this works perfectly for JPEG - lossy images. but crashes when I use the
same on a lossless compressed image.
is there something that I am missing?
Should I be using something from the JPEG-header ?
or does'nt JAVA support lossless decompression?
plz help,
Thanks in advance.
kind regards,
Rajesh Rapaka.

--
R.Rajesh,
Computer Engineer (Java Developer),
Eroglu Software Company,
Eskisehir, Turkey.
[att1.html]

Reply viewing options

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

I am getting this message from your site:

"The web site you are trying to access has exceeded its allocated data
transfer."

Will try again later.

BrIAn

On Tue, 16 Aug 2005, R Rajesh wrote:

> Hello Mr.Brain,
> Here I am sending a simple version of the software. this includes a jar file
> and the source code also. You'll have to download the jar file and the image
> file and run the jar file. click on open and select the S001.dcm file that u
> will have to downloaded. This will give you the error. The part that are in
> blue are originally red in color !
> jar file: http://www.geocities.com/rajesh_rapaka/TestCase.jar
> image file : http://www.geocities.com/rajesh_rapaka/S001.zip
> source code: http://www.geocities.com/rajesh_rapaka/testcase.zip
> I hardly find any hope, since, i am not able to change the methods of JAI
> and IMAGE i/o.
> Hope you have a solution for this. or is this a bug?
> kind regards,
> Rajesh Rapaka.

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

R Rajesh

sorry for that....I guess its a security measure by yahoo. It says it will
be corrected after an hour. Plz try again to download it. If you fail to
download them plz let me know.
regards
Rajesh Rapaka.

On 8/16/05, Brian Burkhalter wrote:
>
> I am getting this message from your site:
>
> "The web site you are trying to access has exceeded its allocated data
> transfer."
>
> Will try again later.
>
> BrIAn
>
> On Tue, 16 Aug 2005, R Rajesh wrote:
>
> > Hello Mr.Brain,
> > Here I am sending a simple version of the software. this includes a jar
> file
> > and the source code also. You'll have to download the jar file and the
> image
> > file and run the jar file. click on open and select the S001.dcm file
> that u
> > will have to downloaded. This will give you the error. The part that are
> in
> > blue are originally red in color !
> > jar file: http://www.geocities.com/rajesh_rapaka/TestCase.jar
> > image file : http://www.geocities.com/rajesh_rapaka/S001.zip
> > source code: http://www.geocities.com/rajesh_rapaka/testcase.zip
> > I hardly find any hope, since, i am not able to change the methods of
> JAI
> > and IMAGE i/o.
> > Hope you have a solution for this. or is this a bug?
> > kind regards,
> > Rajesh Rapaka.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>

--
R.Rajesh,
Computer Engineer (Java Developer),
Eroglu Softwares,
Eskisehir, Turkey.
[att1.html]

Brian Burkhalter

Why are you using a SeekableStream and not an ImageInputSream?

The code snippet looks OK to me. A self-contained test case requiring no
editing would be more useful.

Also, regarding large files, we have a means of providing an FTP upload site
should this be necessary.

Brian

On Thu, 11 Aug 2005, R Rajesh wrote:

> Hi,
> Would you be able to supply a complete self-containted test case with data?
> Mr.Brian, I'd like to send the original dicom image that I am working on,
> But that is a 30 MB file. I feel its no good to do that. So instead I am
> sending a picture of the output that i for using the decoding process below.
> ByteArraySeekableStream seekIs = new ByteArraySeekableStream(
> compressedArray);
>
> ImageReader r = (ImageReader) ImageIO.getImageReadersByFormatName(
> "jpeg-lossless").next();
> ParameterBlock pb = new ParameterBlock();
> pb.add(seekIs);
> pb.add(new Integer(0));
> pb.add(Boolean.FALSE);
> pb.add(Boolean.FALSE);
> pb.add(Boolean.FALSE);
> pb.add(null);
> pb.add(null);
> pb.add(null);
> pb.add(r);
> RenderedOp jpgOp = JAI.create("ImageRead", pb);
> bufferedImage = imge.getAsBufferedImage();
>
>
> My 2 cnt worth: This may not be a JAI problem. I had this same problem with
>> Java2D. I read in some images with ImageIO. Draw them on the screen, no
>> problem. Applied some Java2D filtering (ConvolveOp) and for some images the
>> color bands were effectively swapped. Never did dig into this in depth, just
>> circumvented the problem by drawing the image image first into a second
>> BufferedImage and then applying the filters into that image, not to the
>> original returned from ImageIO. Those images that did not behave correctly
>> were created in a Macintosh Photoshop, so my gues is that this is some sort
>> of endian related problem or that some routine somewhere deep in Java
>> libraries does not pay attention to the type of the Buffereimage in effect
>> ignoring it TYPE_INT_RGB or TYPE_INT_BGR. Or maybe it is not a bug but a
>> feature.
>>
>>
>> Mr. Kustaa, thats a very interesting response. But unfortunately I have no
> Java2D subjects to exchange with JAI. I am using JAI completely to decode
> the jpeg - lossless images. even the renderedOp class is a part of JAI. and
> there is no other function that i can use from jai instead of x !
> how do u think i can solve this problem?
> any ideas?
> thanks n advance,
> regards
>
> Rajesh Rapaka
>

----------------
Brian Burkhalter
Advanced Development/Media & Entertainment
Market Development Engineering
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

R Rajesh

Hello Mr.Brain,
Here I am sending a simple version of the software. this includes a jar file
and the source code also. You'll have to download the jar file and the image
file and run the jar file. click on open and select the S001.dcm file that u
will have to downloaded. This will give you the error. The part that are in
blue are originally red in color !
jar file: http://www.geocities.com/rajesh_rapaka/TestCase.jar
image file : http://www.geocities.com/rajesh_rapaka/S001.zip
source code: http://www.geocities.com/rajesh_rapaka/testcase.zip
I hardly find any hope, since, i am not able to change the methods of JAI
and IMAGE i/o.
Hope you have a solution for this. or is this a bug?
kind regards,
Rajesh Rapaka.
[att1.html]

Brian Burkhalter

Thanks. We'll take a look at it. Others are welcome to comment as well of
course.

Brian

On Tue, 16 Aug 2005, R Rajesh wrote:

> Hello Mr.Brain,
> Here I am sending a simple version of the software. this includes a jar file
> and the source code also. You'll have to download the jar file and the image
> file and run the jar file. click on open and select the S001.dcm file that u
> will have to downloaded. This will give you the error. The part that are in
> blue are originally red in color !
> jar file: http://www.geocities.com/rajesh_rapaka/TestCase.jar
> image file : http://www.geocities.com/rajesh_rapaka/S001.zip
> source code: http://www.geocities.com/rajesh_rapaka/testcase.zip
> I hardly find any hope, since, i am not able to change the methods of JAI
> and IMAGE i/o.
> Hope you have a solution for this. or is this a bug?
> kind regards,
> Rajesh Rapaka.
>

----------------
Brian Burkhalter
Advanced Development/Media & Entertainment
Market Development Engineering
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

R Rajesh

On 8/16/05, Brian Burkhalter wrote:
>
> Thanks. We'll take a look at it. Others are welcome to comment as well
> ofcourse.
>
yes ofcourse. I request other also to write, if u've got any idea as to why
this strange behaviour. What I strongly feel, is it is not just the RED
color that is being converted to BLUE. But it is the whole color map that is
being reversed.
For most of the jpeg images it works perfectly. but for some images, as the
one i've enclosed, i get the reversal of colors. and hence the blue color
instead of RED. (plz check the piece of software i've enclosed in the
earlier mail).
Hoping for a quick solution,
Thanking you,
regards,
Rajesh Rapaka.
[att1.html]

Ken Warner

This couldn't possibly be a byte-swap problem like we used to see in the
old days going
to and from old intel architecture -- could it?

R Rajesh wrote:

>On 8/16/05, Brian Burkhalter wrote:
>
>
>>Thanks. We'll take a look at it. Others are welcome to comment as well
>>ofcourse.
>>
>>
>>
>yes ofcourse. I request other also to write, if u've got any idea as to why
>this strange behaviour. What I strongly feel, is it is not just the RED
>color that is being converted to BLUE. But it is the whole color map that is
>being reversed.
> For most of the jpeg images it works perfectly. but for some images, as the
>one i've enclosed, i get the reversal of colors. and hence the blue color
>instead of RED. (plz check the piece of software i've enclosed in the
>earlier mail).
> Hoping for a quick solution,
>Thanking you,
>regards,
>Rajesh Rapaka.
>
>
>

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

R Rajesh

Hi,
Thank you Mr.Brain, It worked.
Mr.Marco, Are you sure the ImageIO.getImageReadersByFormatName function has
parameters like "jpeg-lossless" and "JPEG-LS"?? I've tried using JPEG and it
worked. But ofcourse this time... i get an error while using
JAI.create("ImageRead",...).
I get a "No operator registered' exception for ImageRead.
I feel i've installed both JAI and ImageI/O. I've added all the jar files
found in their installed folders to the JBUILDER's required libraries.
But still this is case.
any idea?
thanks in advance,
regards
Rajesh Rapaka.

On 7/1/05, Marco Sambin - NeoLogica wrote:
>
> Dear Rajesh,
> here is a modified code snipped related to your example which may help
> you:
> ==============================================================
> ByteArraySeekableStream seekIs = new
> ByteArraySeekableStream(compImageArray);
> // Get the appropriate JPEG reader, depending on your
> // type on DICOM image (it may be "jpeg-lossless", "jpeg-ls", etc.)
> Iterator ite = ImageIO.getImageReadersByFormatName("jpeg-lossless");
> ImageReader r = (ImageReader)ite.next();
> ParameterBlock pb = new ParameterBlock();
> pb.add(seekIs);
> pb.add(new Integer(0));
> pb.add(Boolean.FALSE);
> pb.add(Boolean.FALSE);
> pb.add(Boolean.FALSE);
> pb.add(null);
> pb.add(null);
> pb.add(null);
> pb.add(r);
> RenderedOp jpgOp = JAI.create("ImageRead", pb);
>
> // If you want to obtain a BufferedImage...
> BufferedImage bufImage = jpgOp.getAsBufferedImage();
> ==============================================================
>
> Please notice that in order to get this code working you need to have JAI
> and the JAI Image I/O tools properly installed and configured with your JDK
> / JRE.
> Hope it helps.
> Best regards,
> Marco.
>
> ------------------------------
> *From:* R Rajesh [mailto:rajesh.rapaka@gmail.com]
> *Sent:* venerdì 1 luglio 2005 11.08
> *To:* interest@jai.dev.java.net
> *Subject:* Re: [JAI] lossless jpeg decompression.
>
> Hi,
> It once again says this process is not supported. This is how I tried to
> decode the JPEG image.
> ByteArrayInputStream bais = new ByteArrayInputStream(compImageArray);
> Iterator ite = ImageIO.getImageReadersByFormatName("JPEG");
> ImageReader r = (ImageReader)ite.next();
> ImageInputStream iis = ImageIO.createImageInputStream(bais);
> r.setInput(iis,true);
> BufferedImage bufImage = r.read(0);
> and I still get the same exception:
> javax.imageio.IIOException: Unsupported JPEG process: SOF type 0xc3
> at com.sun.imageio.plugins.jpeg.JPEGImageReader.readImageHeader(Native
> Method)
> at com.sun.imageio.plugins.jpeg.JPEGImageReader.readNativeHeader (
> JPEGImageReader.java:543)
> at com.sun.imageio.plugins.jpeg.JPEGImageReader.checkTablesOnly(
> JPEGImageReader.java:298)
> at com.sun.imageio.plugins.jpeg.JPEGImageReader.gotoImage(
> JPEGImageReader.java:420)
> at com.sun.imageio.plugins.jpeg.JPEGImageReader.readHeader (
> JPEGImageReader.java:536)
> at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(
> JPEGImageReader.java:869)
> at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java
> :853)
> at javax.imageio.ImageReader.read (ImageReader.java:919)
> ....
> Am I doing some mistake somewhere? please help.
> thanks in advance,
> regards,
> Rajesh Rapaka.
> --
> R.Rajesh,
> Computer Engineer (Java Developer),
> Eroglu Software Company,
> Eskisehir, Turkey.
>

--
R.Rajesh,
Computer Engineer (Java Developer),
Eroglu Software Company,
Eskisehir, Turkey.
[att1.html]

Brian Burkhalter

On Mon, 4 Jul 2005, R Rajesh wrote:

> Mr.Marco, Are you sure the ImageIO.getImageReadersByFormatName function has
> parameters like "jpeg-lossless" and "JPEG-LS"?? I've tried using JPEG and it
> worked.

If you have JAI-Image I/O Tools properly installed then any of these format
names should work:

"jpeg", "JPEG", "jpg", "JPG", "jfif", "JFIF",
"jpeg-lossless", "JPEG-LOSSLESS", "jpeg-ls", "JPEG-LS"

as documented

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

> But ofcourse this time... i get an error while using
> JAI.create("ImageRead",...).
> I get a "No operator registered' exception for ImageRead.
> I feel i've installed both JAI and ImageI/O. I've added all the jar files
> found in their installed folders to the JBUILDER's required libraries.
> But still this is case.

I can't speak about JBuilder. Note however that for the JAI-Image Tools JPEG
plugin to work you need the native component as documented here:

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

That should not affect the "ImageRead" installation however.

Brian

----------------
Brian Burkhalter
Advanced Development/Media & Entertainment
Market Development Engineering
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

R Rajesh

Thank you Mr.Brain. It worked already. There was a problem in adding the
Image i/o's jar files to the project. and it worked as soon as i did that.
Thank you,
kind regards,
Rajesh Rapaka.

On 7/11/05, Brian Burkhalter wrote:
>
> On Mon, 4 Jul 2005, R Rajesh wrote:
>
> > Mr.Marco, Are you sure the ImageIO.getImageReadersByFormatName function
> has
> > parameters like "jpeg-lossless" and "JPEG-LS"?? I've tried using JPEG
> and it
> > worked.
>
> If you have JAI-Image I/O Tools properly installed then any of these
> format
> names should work:
>
> "jpeg", "JPEG", "jpg", "JPG", "jfif", "JFIF",
> "jpeg-lossless", "JPEG-LOSSLESS", "jpeg-ls", "JPEG-LS"
>
> as documented
>
>
> http://java.sun.com/products/java-media/jai/forDevelopers/jai-imageio-1_...
>
> > But ofcourse this time... i get an error while using
> > JAI.create("ImageRead",...).
> > I get a "No operator registered' exception for ImageRead.
> > I feel i've installed both JAI and ImageI/O. I've added all the jar
> files
> > found in their installed folders to the JBUILDER's required libraries.
> > But still this is case.
>
> I can't speak about JBuilder. Note however that for the JAI-Image Tools
> JPEG
> plugin to work you need the native component as documented here:
>
>
> http://java.sun.com/products/java-media/jai/forDevelopers/jai-imageio-1_...
>
> That should not affect the "ImageRead" installation however.
>
> Brian
>
> ----------------
> Brian Burkhalter
> Advanced Development/Media & Entertainment
> Market Development Engineering
> 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
>
>

--
R.Rajesh,
Computer Engineer (Java Developer),
Eroglu Software Company,
Eskisehir, Turkey.
[att1.html]

R Rajesh

Hi,
I feel like I've found an error in the JPEG - lossless color images
decompression. Well as of now, I feel I have no explanation for this strange
behaviour of the library.
This is how I am decompressing a loss-less image type:
ByteArraySeekableStream seekIs = new
ByteArraySeekableStream(compImageArray);
// Get the appropriate JPEG reader, depending on your
// type on DICOM image (it may be "jpeg-lossless", "jpeg-ls", etc.)
Iterator ite = ImageIO.getImageReadersByFormatName("jpeg-lossless");
ImageReader r = (ImageReader)ite.next();
ParameterBlock pb = new ParameterBlock();
pb.add(seekIs);
pb.add(new Integer(0));
pb.add(Boolean.FALSE);
pb.add(Boolean.FALSE);
pb.add(Boolean.FALSE);
pb.add(null);
pb.add(null);
pb.add(null);
pb.add(r);
RenderedOp jpgOp = JAI.create("ImageRead", pb);

// If you want to obtain a BufferedImage...
BufferedImage bufImage = jpgOp.getAsBufferedImage();
a code help from Mr.Marco.
It works perfectly for some images. But for some images, If I had the Red
color in the pixels, I am getting a blue color. and in the place of blue
pixels i am getting RED !! More into observation I observed that the whole
color scheme is reversed. But at the same time I see the Black and the White
colors are untouched !!!
Can anyone explain what could be the reason for this strange bhaviour??
Thanking you,
kind regards,
Rajesh Rapaka.
[att1.html]

Brian Burkhalter

I would have no a priori explanation for this behavior.

Would you be able to supply a complete self-containted test case with data?

Brian

On Mon, 8 Aug 2005, R Rajesh wrote:

> It works perfectly for some images. But for some images, If I had the Red
> color in the pixels, I am getting a blue color. and in the place of blue
> pixels i am getting RED !! More into observation I observed that the whole
> color scheme is reversed. But at the same time I see the Black and the White
> colors are untouched !!!
> Can anyone explain what could be the reason for this strange bhaviour??

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

zqwu
Offline
Joined: 2005-10-03

Hi,
I tried displaying a 12-bit Jpeg-lossless image downloaded from:
ftp://figment.csee.usf.edu/pub/DDSM/cases/cancers/cancer_01/case3008/B_3...

I have read some relevant messages in JAI forum and used the following codes to display the image:
ByteArraySeekableStream seekIs = new
ByteArraySeekableStream(compImageArray);
// Get the appropriate JPEG reader, depending on your
// type on DICOM image (it may be "jpeg-lossless", "jpeg-ls", etc.)
Iterator ite = ImageIO.getImageReadersByFormatName("jpeg-lossless");
ImageReader r = (ImageReader)ite.next();
ParameterBlock pb = new ParameterBlock();
pb.add(seekIs);
pb.add(new Integer(0));
pb.add(Boolean.FALSE);
pb.add(Boolean.FALSE);
pb.add(Boolean.FALSE);
pb.add(null);
pb.add(null);
pb.add(null);
pb.add(r);
RenderedOp jpgOp = JAI.create("ImageRead", pb);

However, the displayed image is not correct (not due to enhancement). I think the parameters (except seekIs and r) added to ParameterBlock might be not correct.

Does anyone know the meaning of the rest parameters so I can try to change them. I am not able to find relevant information about these parameters on JAI's home page.

Please help,
Many thanks,

Zhi Qing

Brian Burkhalter

See for example

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

Brian

On Fri, 14 Oct 2005, jai-interest@javadesktop.org wrote:

> Hi,
> I tried displaying a 12-bit Jpeg-lossless image downloaded from:
> ftp://figment.csee.usf.edu/pub/DDSM/cases/cancers/cancer_01/case3008/B_3...
>
> I have read some relevant messages in JAI forum and used the following codes to display the image:
> ByteArraySeekableStream seekIs = new
> ByteArraySeekableStream(compImageArray);
> // Get the appropriate JPEG reader, depending on your
> // type on DICOM image (it may be "jpeg-lossless", "jpeg-ls", etc.)
> Iterator ite = ImageIO.getImageReadersByFormatName("jpeg-lossless");
> ImageReader r = (ImageReader)ite.next();
> ParameterBlock pb = new ParameterBlock();
> pb.add(seekIs);
> pb.add(new Integer(0));
> pb.add(Boolean.FALSE);
> pb.add(Boolean.FALSE);
> pb.add(Boolean.FALSE);
> pb.add(null);
> pb.add(null);
> pb.add(null);
> pb.add(r);
> RenderedOp jpgOp = JAI.create("ImageRead", pb);
>
> However, the displayed image is not correct (not due to enhancement). I think the parameters (except seekIs and r) added to ParameterBlock might be not correct.
>
> Does anyone know the meaning of the rest parameters so I can try to change them. I am not able to find relevant information about these parameters on JAI's home page.
>
> Please help,
> Many thanks,
>
> Zhi Qing
> ---
> [Message sent by forum member 'zqwu' (Zhi Qing)]
>
> http://www.javadesktop.org/forums/thread.jspa?messageID=119497&#119497
>
> ---------------------------------------------------------------------
> 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

Kustaa Nyholm

My 2 cnt worth: This may not be a JAI problem. I had this same problem with Java2D. I read in some images with ImageIO. Draw them on the screen, no problem. Applied some Java2D filtering (ConvolveOp) and for some images the color bands were effectively swapped. Never did dig into this in depth, just circumvented the problem by drawing the image image first into a second BufferedImage and then applying the filters into that image, not to the original returned from ImageIO. Those images that did not behave correctly were created in a Macintosh Photoshop, so my gues is that this is some sort of endian related problem or that some routine somewhere deep in Java libraries does not pay attention to the type of the Buffereimage in effect ignoring it TYPE_INT_RGB or TYPE_INT_BGR. Or maybe it is not a bug but a feature.

r Kusti

Kustaa Nyholm
Research Manager, Software
Research and Technology Division
PLANMECA OY
Asentajankatu 6
00880 HELSINKI
FINLAND

Please note our new telephone and fax numbers!
Tel: +358 20 7795 572 (direct)
Fax: +358 20 7795 676
GSM: +358 40 580 5193
e-mail: kustaa.nyholm@planmeca.com

This e-mail may contain confidential or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. We will not be liable for direct, indirect, special or consequential damages arising from alteration of the contents of this message by a third party or as a result of any virus being passed for viruses.

>>> Brian.Burkhalter@Sun.COM 9.8.2005 1:54 >>>
I would have no a priori explanation for this behavior.

Would you be able to supply a complete self-containted test case with data?

Brian

On Mon, 8 Aug 2005, R Rajesh wrote:

> It works perfectly for some images. But for some images, If I had the Red
> color in the pixels, I am getting a blue color. and in the place of blue
> pixels i am getting RED !! More into observation I observed that the whole
> color scheme is reversed. But at the same time I see the Black and the White
> colors are untouched !!!
> Can anyone explain what could be the reason for this strange bhaviour??

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

R Rajesh

Hi,
Would you be able to supply a complete self-containted test case with data?
Mr.Brian, I'd like to send the original dicom image that I am working on,
But that is a 30 MB file. I feel its no good to do that. So instead I am
sending a picture of the output that i for using the decoding process below.
ByteArraySeekableStream seekIs = new ByteArraySeekableStream(
compressedArray);

ImageReader r = (ImageReader) ImageIO.getImageReadersByFormatName(
"jpeg-lossless").next();
ParameterBlock pb = new ParameterBlock();
pb.add(seekIs);
pb.add(new Integer(0));
pb.add(Boolean.FALSE);
pb.add(Boolean.FALSE);
pb.add(Boolean.FALSE);
pb.add(null);
pb.add(null);
pb.add(null);
pb.add(r);
RenderedOp jpgOp = JAI.create("ImageRead", pb);
bufferedImage = imge.getAsBufferedImage();

My 2 cnt worth: This may not be a JAI problem. I had this same problem with
> Java2D. I read in some images with ImageIO. Draw them on the screen, no
> problem. Applied some Java2D filtering (ConvolveOp) and for some images the
> color bands were effectively swapped. Never did dig into this in depth, just
> circumvented the problem by drawing the image image first into a second
> BufferedImage and then applying the filters into that image, not to the
> original returned from ImageIO. Those images that did not behave correctly
> were created in a Macintosh Photoshop, so my gues is that this is some sort
> of endian related problem or that some routine somewhere deep in Java
> libraries does not pay attention to the type of the Buffereimage in effect
> ignoring it TYPE_INT_RGB or TYPE_INT_BGR. Or maybe it is not a bug but a
> feature.
>
>
> Mr. Kustaa, thats a very interesting response. But unfortunately I have no
Java2D subjects to exchange with JAI. I am using JAI completely to decode
the jpeg - lossless images. even the renderedOp class is a part of JAI. and
there is no other function that i can use from jai instead of x !
how do u think i can solve this problem?
any ideas?
thanks n advance,
regards

Rajesh Rapaka
[att1.html]
[jpeglossless.JPG]
---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

R Rajesh

I am so sorry, I've not explained anything about the image i got. the image
i've attached is an image of an eye. where all the blue parts are supposed
to be RED. and the rest are the same. why are we getting this blue color
??!!
any ideas?
Thanks in advance.
regards
Rajesh Rapaka
[att1.html]

Brian Burkhalter

JAI does not support lossless JPEG. For this you need to use JAI-Image I/O
Tools. Please go to the JAI home page on java.sun.com and select "Download"
where you will see the download pages for this separate package.

Brian

On Wed, 29 Jun 2005, R Rajesh wrote:

> Hi all,
> I am trying to decode the Jpeg compression using JPEGImageDecoder class. I
> am sucessfully able to decode the 'Lossy Jpeg Compression'. But for lossless
> the same function crashes. this is how i am doing it.
> I am using this for decoding Dicom images that are compressed with JPEG.
> In this, after the header, the JPEG header and pixels are also encapsulated
> in seperate tags.
> I've taken the pixels from the encapsulation and made a stream from it, thus
> enabling the JPEGImageDecoder class to decode the image.
> this works perfectly for JPEG - lossy images. but crashes when I use the
> same on a lossless compressed image.
> is there something that I am missing?
> Should I be using something from the JPEG-header ?
> or does'nt JAVA support lossless decompression?
> plz help,
> Thanks in advance.
> kind regards,
> Rajesh Rapaka.
>
> --
> R.Rajesh,
> Computer Engineer (Java Developer),
> Eroglu Software Company,
> Eskisehir, Turkey.
>

----------------
Brian Burkhalter
Advanced Development/Media & Entertainment
Market Development Engineering
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

R Rajesh

Hi,
Thank you for the information. I've installed the image i.o tool. But i
failed to implement it. i mean i am not able to understand how to use it.
Well i've downloaded the imageI/O documentation. But it didnt help much. I
tried using the ImageReader class. But couldnt finish it. Are there any good
sources of api's or examples that can guide me?
plz help,
Thanks in Advance,
regards,
Rajesh Rapaka.

On 6/29/05, Brian Burkhalter wrote:
>
> JAI does not support lossless JPEG. For this you need to use JAI-Image I/O
> Tools. Please go to the JAI home page on java.sun.comand select "Download"
> where you will see the download pages for this separate package.
>
> Brian
>
> On Wed, 29 Jun 2005, R Rajesh wrote:
>
> > Hi all,
> > I am trying to decode the Jpeg compression using JPEGImageDecoder class.
> I
> > am sucessfully able to decode the 'Lossy Jpeg Compression'. But for
> lossless
> > the same function crashes. this is how i am doing it.
> > I am using this for decoding Dicom images that are compressed with JPEG.
> > In this, after the header, the JPEG header and pixels are also
> encapsulated
> > in seperate tags.
> > I've taken the pixels from the encapsulation and made a stream from it,
> thus
> > enabling the JPEGImageDecoder class to decode the image.
> > this works perfectly for JPEG - lossy images. but crashes when I use the
> > same on a lossless compressed image.
> > is there something that I am missing?
> > Should I be using something from the JPEG-header ?
> > or does'nt JAVA support lossless decompression?
> > plz help,
> > Thanks in advance.
> > kind regards,
> > Rajesh Rapaka.
> >
> > --
> > R.Rajesh,
> > Computer Engineer (Java Developer),
> > Eroglu Software Company,
> > Eskisehir, Turkey.
> >
>
> ----------------
> Brian Burkhalter
> Advanced Development/Media & Entertainment
> Market Development Engineering
> 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
>
>

--
R.Rajesh,
Computer Engineer (Java Developer),
Eroglu Software Company,
Eskisehir, Turkey.
[att1.html]

Brian Burkhalter

You can get to all the docs from here

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

Brian

On Thu, 30 Jun 2005, R Rajesh wrote:

> Hi,
> Thank you for the information. I've installed the image i.o tool. But i
> failed to implement it. i mean i am not able to understand how to use it.
> Well i've downloaded the imageI/O documentation. But it didnt help much. I
> tried using the ImageReader class. But couldnt finish it. Are there any good
> sources of api's or examples that can guide me?
> plz help,
> Thanks in Advance,
> regards,
> Rajesh Rapaka.
>
> On 6/29/05, Brian Burkhalter wrote:
> >
> > JAI does not support lossless JPEG. For this you need to use JAI-Image I/O
> > Tools. Please go to the JAI home page on java.sun.comand select "Download"
> > where you will see the download pages for this separate package.
> >
> > Brian
> >
> > On Wed, 29 Jun 2005, R Rajesh wrote:
> >
> > > Hi all,
> > > I am trying to decode the Jpeg compression using JPEGImageDecoder class.
> > I
> > > am sucessfully able to decode the 'Lossy Jpeg Compression'. But for
> > lossless
> > > the same function crashes. this is how i am doing it.
> > > I am using this for decoding Dicom images that are compressed with JPEG.
> > > In this, after the header, the JPEG header and pixels are also
> > encapsulated
> > > in seperate tags.
> > > I've taken the pixels from the encapsulation and made a stream from it,
> > thus
> > > enabling the JPEGImageDecoder class to decode the image.
> > > this works perfectly for JPEG - lossy images. but crashes when I use the
> > > same on a lossless compressed image.
> > > is there something that I am missing?
> > > Should I be using something from the JPEG-header ?
> > > or does'nt JAVA support lossless decompression?
> > > plz help,
> > > Thanks in advance.
> > > kind regards,
> > > Rajesh Rapaka.
> > >
> > > --
> > > R.Rajesh,
> > > Computer Engineer (Java Developer),
> > > Eroglu Software Company,
> > > Eskisehir, Turkey.
> > >
> >
> > ----------------
> > Brian Burkhalter
> > Advanced Development/Media & Entertainment
> > Market Development Engineering
> > 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
> >
> >
>
>
> --
> R.Rajesh,
> Computer Engineer (Java Developer),
> Eroglu Software Company,
> Eskisehir, Turkey.
>

----------------
Brian Burkhalter
Advanced Development/Media & Entertainment
Market Development Engineering
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

R Rajesh

Hi,
It once again says this process is not supported. This is how I tried to
decode the JPEG image.
ByteArrayInputStream bais = new ByteArrayInputStream(compImageArray);
Iterator ite = ImageIO.getImageReadersByFormatName("JPEG");
ImageReader r = (ImageReader)ite.next();
ImageInputStream iis = ImageIO.createImageInputStream(bais);
r.setInput(iis,true);
BufferedImage bufImage = r.read(0);
and I still get the same exception:
javax.imageio.IIOException: Unsupported JPEG process: SOF type 0xc3
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readImageHeader(Native
Method)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readNativeHeader(
JPEGImageReader.java:543)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.checkTablesOnly(
JPEGImageReader.java:298)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.gotoImage(
JPEGImageReader.java:420)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readHeader(
JPEGImageReader.java:536)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(
JPEGImageReader.java:869)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java
:853)
at javax.imageio.ImageReader.read(ImageReader.java:919)
....
Am I doing some mistake somewhere? please help.
thanks in advance,
regards,
Rajesh Rapaka.
--
R.Rajesh,
Computer Engineer (Java Developer),
Eroglu Software Company,
Eskisehir, Turkey.
[att1.html]

Marco Sambin - NeoLogica

Dear Rajesh,

here is a modified code snipped related to your example which may help you:

==============================================================

ByteArraySeekableStream seekIs = new
ByteArraySeekableStream(compImageArray);

// Get the appropriate JPEG reader, depending on your
// type on DICOM image (it may be "jpeg-lossless", "jpeg-ls",
etc.)
Iterator ite =
ImageIO.getImageReadersByFormatName("jpeg-lossless");
ImageReader r = (ImageReader)ite.next();

ParameterBlock pb = new ParameterBlock();
pb.add(seekIs);
pb.add(new Integer(0));
pb.add(Boolean.FALSE);
pb.add(Boolean.FALSE);
pb.add(Boolean.FALSE);
pb.add(null);
pb.add(null);
pb.add(null);
pb.add(r);

RenderedOp jpgOp = JAI.create("ImageRead", pb);

// If you want to obtain a BufferedImage...
BufferedImage bufImage = jpgOp.getAsBufferedImage();

==============================================================

Please notice that in order to get this code working you need to have JAI
and the JAI Image I/O tools properly installed and configured with your JDK
/ JRE.
Hope it helps.

Best regards,

Marco.

_____

From: R Rajesh [mailto:rajesh.rapaka@gmail.com]
Sent: venerdì 1 luglio 2005 11.08
To: interest@jai.dev.java.net
Subject: Re: [JAI] lossless jpeg decompression.

Hi,
It once again says this process is not supported. This is how I tried to
decode the JPEG image.

ByteArrayInputStream bais = new ByteArrayInputStream(compImageArray);
Iterator ite = ImageIO.getImageReadersByFormatName("JPEG");
ImageReader r = (ImageReader)ite.next();
ImageInputStream iis = ImageIO.createImageInputStream(bais);
r.setInput(iis,true);
BufferedImage bufImage = r.read(0);

and I still get the same exception:
javax.imageio.IIOException: Unsupported JPEG process: SOF type 0xc3
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readImageHeader(Native
Method)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readNativeHeader
(JPEGImageReader.java:543)
at
com.sun.imageio.plugins.jpeg.JPEGImageReader.checkTablesOnly(JPEGImageReader
.java:298)
at
com.sun.imageio.plugins.jpeg.JPEGImageReader.gotoImage(JPEGImageReader.java:
420)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readHeader
(JPEGImageReader.java:536)
at
com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.ja
va:869)
at
com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:853)
at javax.imageio.ImageReader.read (ImageReader.java:919)
....

Am I doing some mistake somewhere? please help.
thanks in advance,
regards,
Rajesh Rapaka.
--
R.Rajesh,
Computer Engineer (Java Developer),
Eroglu Software Company,
Eskisehir, Turkey.
[att1.html]

R Rajesh

Hi,
I am trying to install " jai-1_1_2-lib-windows-i586-jdk " the JAI's jdk.
I get the following message: "This program requires the installation * of
Java2 SDK** version 1.3" . *
well i've installed sdk version 1.4 also. still i get the same error
message. I felt installing sdk 1.3 wud be foolish enough !
I am installing this on Windows XP, with sp2. Can anyone help? its really
urgent. did anyone come accross this problem?
thanks in advance,
regards,
Rajesh Rapaka.

R.Rajesh,
Computer Engineer (Java Developer),
Eroglu Software Company,
Eskisehir, Turkey.
[att1.html]

Brian Burkhalter

> I am trying to install " jai-1_1_2-lib-windows-i586-jdk " the JAI's jdk.
> I get the following message: "This program requires the installation * of
> Java2 SDK** version 1.3" . *
> well i've installed sdk version 1.4 also. still i get the same error
> message. I felt installing sdk 1.3 wud be foolish enough !
> I am installing this on Windows XP, with sp2.

This is a bug which was fixed in JAI 1.1.2_01. Please try the newer version.

> Can anyone help? its really
> urgent.

It always is, isn't it? ;-)

Regards,

Brian

> did anyone come accross this problem?
> thanks in advance,
> regards,
> Rajesh Rapaka.
>
> R.Rajesh,
> Computer Engineer (Java Developer),
> Eroglu Software Company,
> Eskisehir, Turkey.
>

----------------
Brian Burkhalter
Advanced Development/Media & Entertainment
Market Development Engineering
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