开发者

I can't get an ImageReaderByFormatName("jpeg-lossless")

I am trying to decode a lossless jpeg using JAI_ImageIO library and the following java call:

ImageIO.getImageReadersByFormatName("jpeg-lossless").hasNext()

results in "null".

NOTE: I have the JAI_ImageIO jar installed to my jre/lib/ext directory.

I don't know if the JPEG reader is sufficient to read lossless jpegs or if another reader is required to be installed.

When I enumerate the FormatNames, i.e.:

ImageIO.getReaderFormatNames()

I get the following formats:

[raw, jpeg, tif, WBMP, PNM, JPG, DICOM, wbmp, JPEG, PNG, jpeg 2000, 
tiff, BMP, JPEG2000, RAW, jpeg2000, GIF, TIF, TIFF, jpg, bmp, pnm, 
png, JPEG 2000, gif]

I get the following runtime exception when I try to use the JPEG2000 reader:

java.lang.RuntimeException: File is neither valid JP2 file nor valid JPEG 2000 codestream
at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.initializeRead(J2KReadState.java:696)
at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.<init>(J2KReadState.java:209)
at com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReader.read(J2KImageReader.java:449)
at javax.imageio.ImageReader.read(Imag开发者_运维技巧eReader.java:940)

When I try to

ImageIO.read(file)

directly I get a an org.dcm4cheri.image.ConfigurationException.


OK, I found the answer to my particular problem and I believe it will solve the more general problem of how to install JAI_ImageIO properly at least on *NIX based operating system.

After reading the following (Obscure place on the WWW) and attempting all 3 installation alternatives of JAI_ImageIO described here. (I should've also made mention that I am running on a Debian 6.0 64bit platform.)

After settling with the manual "installation type" I realized that my LD_LIBRARY_PATH variable wasn't being picked up. So I decided to force the issue and add a soft link to the libclib_jiio.so in my /usr/lib. Lo and behold it worked.

I used the code provided here to determine if my JAI_ImageIO was installed properly, and when it is installed properly you should see a "JPEG-LOSSLESS" formats/providers in the output!

Thanks for the suggestions. I will try to expand the question to make it more general to the problem of installing JAI_ImageIO pro


I do not think jpeg-lossless is a valid format for JAI. Try listing your available formats:

String[] formats =  ImageIO.getReaderFormatNames();
for ( String format : formats ) {
    System.out.println(format);
}

I think what you actually want is "JPEG2000".

Have you also just tried ImageIO.read(file). That should successfully read DICOM files if you have JAI installed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜