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

查看:51
本文介绍了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.请帮忙.

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天全站免登陆