1
votes

Here's my question. I have a bmp file and try to get the RGB values of the picture. I used 4 different ways to accomplish that, imread in Matlab, package "bmp" and "pixmap" in R, photoshop. However, for the same pixel point, these 4 methods return slightly different values.

  1. imread() in Matlab and read.bmp() in package "bmp" in R return the same values: (155, 92, 75)

  2. getChannels() in package "pixmap" in R returns (0.6431535, 0.3817427, 0.3112033): they seem to be normalized. Dividing the values obtained in point 1 by the range of red channel in the pic ([0,241]) gets exactly the same values. And the range of green and blue channel is [0,187] and [0,176].

  3. Photoshop returns slightly different values: (160, 95, 77).

Why are these methods returns different RGB values? Any help will be appreciated.

Updated information:

Original image (open with Preview in Mac ox and ps): original

Matlab imread() and imshow() image: Matlab version

And I found if I convert the color mode from RGB to CYMK in photoshop, the pic looks much the same as the one in Matlab.

1
Can you upload the actual image here?Suever
I gues the original BMP image is not stored in RGB24 color format (one byte per color channel). Try: I = imread('QMWLH.bmp'); display size(I), make sure the size is 640x360x3. Save I imwrite(I, 'RGB.bmp'); now open RGB.bmp in Photoshop, and check values. Might also be gamma related...Rotem
Another idia: It might be related to Photoshop display prpopeties. It is unlikelly photoshop canges pixel values, but it might be that Photoshop dispay pixel values in Adobe RGB instead of sRGB. (i.e only dispalyed value is different).Rotem

1 Answers

1
votes

Matlab and R are designed for scientific or technical applications, and will read in an image directly unchanged. Photoshop, however, is designed for aesthetic applications, and cares much more about the overall appearance of a given image. One of the more important things to do with representations of colour in an image is the colour space it was acquired in, defining the range (or gamut) of representable shades.

Whilst you haven't shown us the image in question, it's very likely that if it lacked an embedded profile, Photoshop assumed your image was in the standard RGB colour space, sRGB. Since your monitor probably has a different gamut, and by default photoshop uses Adobe RGB to represent images (as it's slightly wider than sRGB), it probably converted it silently to the "new" space. As illustrated below, the two are slightly different:

Adobe RGB

-- and, hence the values reported are slightly different.

In short, if you want to make great holiday snaps, use Photoshop. If you want to do good science, stay the hell away from it.