简体   繁体   English

Skimage Python 从图片中读取的像素值与 Java/Photoshop 不同

[英]Skimage Python reads different Pixel-Values from Picture than Java/Photoshop

I want to read the same values from a picture in Python and Java.我想从 Python 和 Java 的图片中读取相同的值。 In python, i use skimage's imread, in Java i use ImageIO.read().在 python 中,我使用 skimage 的 imread,在 Java 中,我使用 ImageIO.read()。

I expect that the two results are pixel-wise equal, but they are not.我希望这两个结果在像素方面是相等的,但事实并非如此。 Photoshop displays the same values as Javas ImageIO, but skimage's result is different. Photoshop 显示的值与 Java 的 ImageIO 相同,但 skimage 的结果不同。

Here are the lines for Java:以下是 Java 的行:

BufferedImage bi = ImageIO.read(new FileInputStream("/Users/.../Downloads/model/input/123456789.jpg"));
bi.getData().getPixel(10,100,new int[3]) //result = [102, 121, 128]

And here for Python: Python 在这里:

image = io.imread("/Users/.../Downloads/model/input/123456789.jpg")
image[10][100] #result = [109, 126, 133]

My input Image is RGB and has a sRGB profile.我的输入图像是 RGB 并且具有 sRGB 配置文件。 I tried attaching different profiles or removing it completely, without success.我尝试附加不同的配置文件或完全删除它,但没有成功。 I also tried using different libraries for Java(like https://github.com/bytedeco/javacv ) and/or Python... I tried converting to PNG before reading it, but the two results are never truly equal.我还尝试使用不同的 Java 库(如https://github.com/bytedeco/javacv )和/或 Python ......我尝试在阅读它之前转换为 PNG,但两个结果永远不会真正相等。 Why is that?这是为什么?

Here is the image: https://drive.google.com/file/d/1FEWYS4HNZ-SpYCQBx0gQIt-662yjxLfV/view?usp=sharing这是图片: https://drive.google.com/file/d/1FEWYS4HNZ-SpYCQBx0gQIt-662yjxLfV/view?usp=sharing

I have found the solution.我找到了解决方案。

When reading with skimage in python, i get a HxWxC image, but with ImageIO.read() in Java, i get a WxHxC image.在 python 中使用 skimage 读取时,我得到一个 HxWxC 图像,但在 Java 中使用 ImageIO.read(),我得到一个 WxHxC 图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM