我无法获得 ImageReaderByFormatName(“jpeg-lossless”)
我正在尝试使用 JAI_ImageIO 库和以下 java 调用解码无损 jpeg:
ImageIO.getImageReadersByFormatName("jpeg-lossless").hasNext()
结果为“null”。
注意:我已将 JAI_ImageIO jar 安装到 jre/lib/ext 目录中。
我不知道 JPEG 阅读器是否足以读取无损 jpeg,或者是否需要安装另一个阅读器。
当我枚举 FormatNames 时,即:
ImageIO.getReaderFormatNames()
我得到以下格式:
[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]
当我尝试使用 JPEG2000 阅读器时,我得到以下运行时异常:
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(ImageReader.java:940)
当我尝试直接使用
ImageIO.read(file)
时,我得到 org.dcm4cheri.image.ConfigurationException。
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(ImageReader.java:940)
When I try to
ImageIO.read(file)
directly I get a an org.dcm4cheri.image.ConfigurationException.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的,我找到了我的特定问题的答案,我相信它将解决如何至少在基于 *NIX 的操作系统上正确安装 JAI_ImageIO 的更普遍的问题。
阅读以下内容后(WWW 上的不起眼的地方)并尝试描述的 JAI_ImageIO 的所有 3 个安装替代方案 此处。 (我还应该提到我正在 Debian 6.0 64 位平台上运行。)
在解决了 manual "安装类型" 我意识到我的 LD_LIBRARY_PATH 变量没有被选取。所以我决定强制解决这个问题,并在我的/usr/lib中添加一个到libclib_jiio.so的软链接。你瞧,它成功了。
我使用了提供的代码 此处 确定我的 JAI_ImageIO 是否安装正确,安装正确后,您应该在输出中看到“JPEG-LOSSLESS”格式/提供程序!
感谢您的建议。我将尝试扩展问题,使其更普遍地解决安装 JAI_ImageIO pro 的问题
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
我不认为 jpeg-lossless 是 JAI 的有效格式。尝试列出您可用的格式:
我认为您真正想要的是“JPEG2000”。
您是否也刚刚尝试过 ImageIO.read(file)?如果您安装了 JAI,那么应该可以成功读取 DICOM 文件。
I do not think jpeg-lossless is a valid format for JAI. Try listing your available formats:
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.