When i use getRGB() and after that get pixel color Red or Green or Blue component (it does not matter because they equal in Gray image) and compare result with MS Paint Eyedropper result, its different things.
当我使用getRGB()之后,获得像素颜色红色或绿色或蓝色组件(因为它们在灰色图像中相等无关紧要)并将结果与MS Paint Eyedropper结果进行比较,它的不同之处。
import java.awt.Color;
import java.awt.color.ColorSpace;
import java.awt.image.BufferedImage;
import java.awt.image.ColorConvertOp;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.imageio.ImageIO;
public class Separator {
BufferedImage inputImg;
private int _inpupImgWidth;
private int _inpupImgHeight;
public Separator(){
try {
inputImg = ImageIO.read(new File("inputImg.bmp"));
_inpupImgWidth = inputImg.getWidth();
_inpupImgHeight = inputImg.getHeight();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(getGrayPixelData(60, 44));
try {
ImageIO.write(inputImg, "BMP", new File("outputImg.bmp"));
} catch (IOException e) {
e.printStackTrace();
}
}
public void getGrayPixelData(int x, int y){
Color myColor = new Color(inputImg.getRGB(x, y));
System.out.println("Red: " + myColor.getRed());
System.out.println("Green: " + myColor.getGreen());
System.out.println("Blue: " + myColor.getBlue());
}
public static void main(String[] args) {
new Separator();
System.out.println("The End");
}
}
here is the link of image i use http://postimage.org/image/t6tvlv941/
这里是我使用http://postimage.org/image/t6tvlv941/的图像链接
1 个解决方案
#1
0
The image is in greyscale mode.
图像处于灰度模式。
How you convert a greyscale value into R, G, B is quite arbitrary.
如何将灰度值转换为R,G,B是非常随意的。
A naive way would be to assign an identical greyscale value to each of the R, G and B components.
一种天真的方式是为每个R,G和B分量分配相同的灰度值。
A more sophisticated way would be to use some transformation that takes into account the eye's sensitivity to these different components, or which takes account of the profile of your monitor or other display device.
更复杂的方法是使用一些转换,考虑到眼睛对这些不同组件的敏感度,或者考虑到显示器或其他显示设备的配置文件。
So clearly, Java and your program are using different transformations. But in either case, the precise R, G and B values are essentially meaningless: the original data is not in R, G, B format.
很明显,Java和你的程序正在使用不同的转换。但在任何一种情况下,精确的R,G和B值基本上都没有意义:原始数据不是R,G,B格式。
#1
0
The image is in greyscale mode.
图像处于灰度模式。
How you convert a greyscale value into R, G, B is quite arbitrary.
如何将灰度值转换为R,G,B是非常随意的。
A naive way would be to assign an identical greyscale value to each of the R, G and B components.
一种天真的方式是为每个R,G和B分量分配相同的灰度值。
A more sophisticated way would be to use some transformation that takes into account the eye's sensitivity to these different components, or which takes account of the profile of your monitor or other display device.
更复杂的方法是使用一些转换,考虑到眼睛对这些不同组件的敏感度,或者考虑到显示器或其他显示设备的配置文件。
So clearly, Java and your program are using different transformations. But in either case, the precise R, G and B values are essentially meaningless: the original data is not in R, G, B format.
很明显,Java和你的程序正在使用不同的转换。但在任何一种情况下,精确的R,G和B值基本上都没有意义:原始数据不是R,G,B格式。