IllegalArgumentException:源栅格波段和源颜色空间组件的数量不匹配对于彩色图像异常 [英] IllegalArgumentException: Numbers of source Raster bands and source color space components do not match For a color image Exception

查看:832
本文介绍了IllegalArgumentException:源栅格波段和源颜色空间组件的数量不匹配对于彩色图像异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人建议的上述答案将我的彩色图像转换为黑白图像。所以这不适合我的问题。

The above answer that someone has suggest, converts my colored image to a black and white one. So it's not appropriate for my question.

File file = new File("path");          
BufferedImage bufferedImage = ImageIO.read( file );

这里是代码,下面是图片。下载图像并保存在您的电脑中。并尝试使用正确的路径值运行上述代码,它将在主题中抛出异常

here is the code and below is the image. Download the image and save in your pc. And try to run the above code with a correct value of path, it will throw an exception in the topic

下载图片: https://skydrive.live.com/?cid=19547371C4F3B839&id=19547371C4F3B839%21105

如果有人可以从给定足够的图像中获取java.awt.image.BufferedImage对象(不应该将图像转换为灰度图像)。

Simply if someone can obtain a java.awt.image.BufferedImage object from the image given that's enough (should not convert the image to gray scale one).

如果你能回答这个问题,你就是天才:D。 Plz帮助。

You are a genius if you can answer this :D. Plz help.

推荐答案

这里的代码没有任何问题。我可以使用我的用于ImageIO的 JPEGImageReader 插件来阅读您的图像。这个图像阅读器试图对JPEG错误宽容,并且比标准的Java JPEGImageReader稍微强大。

There's nothing wrong with your code here. I could read your image using my JPEGImageReader plugin for ImageIO. This image reader tries to be lenient about JPEG errors, and is slightly more capable than the standard Java JPEGImageReader.

然而,你的JPEG文件似乎有很多问题所以它不能100%读取:

However, your JPEG file seems to have a number of problems so it can't be read 100%:


  • 首先,图像中的ICC颜色配置文件有4个颜色分量,而图像数据有只有3个颜色组件(这会导致您看到的异常)。根本原因可能是糟糕的转换软件。使用ExifTool或类似软件查看元数据以进行进一步调查。我的读者会忽略ICC配置文件。

  • 其次,JPEG流过早结束(缺少EOI)。您会注意到图像右下方有一些垃圾像素。除了获取原始图像之外,没有什么可以做的(实际上,图像包含缩略图并且缩略图没有损坏;如果您确实需要,可以尝试从中重新创建数据)。从我的阅读器返回的图像与本机软件读取的图像一致。

这篇关于IllegalArgumentException:源栅格波段和源颜色空间组件的数量不匹配对于彩色图像异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆