JPEG images have different pixel values across multiple devices

前端 未结 6 1669
别那么骄傲
别那么骄傲 2020-11-27 21:27

I had noticed that when reading in an identical photograph across devices in the JPEG format, the pixel values do not match up. They are close, but different. When convert

6条回答
  •  误落风尘
    2020-11-27 22:17

    Yes, the pixel color values are different across devices. This is very annoying especially if you want to compare colors. The solution is to compare visually equal colors (by human perception).

    One of the best methods to compare two colors by human perception is CIE76. The difference is called Delta-E. When it is less than 1, the human eye can not recognize the difference.

    You can find wonderful color utilities class (ColorUtils), which includes CIE76 comparison methods. It is written by Daniel Strebel,University of Zurich.

    From ColorUtils.class I use the method:

    static double colorDifference(int r1, int g1, int b1, int r2, int g2, int b2)
    

    r1,g1,b1 - RGB values of the first color

    r2,g2,b2 - RGB values ot the second color that you would like to compare

    If you work with Android, you can get these values like this:

    r1 = Color.red(pixel);

    g1 = Color.green(pixel);

    b1 = Color.blue(pixel);

提交回复
热议问题