
How do i get the RGB value of a pixel ? I am using 'misc.imread' module of 'SciPy' to load the image file. When i type : myimage[x,y] It gives me a single value. What value is this exactly? And how do i get the exact RGB value of the pixel?

On Sun, Feb 23, 2014 at 3:18 AM, Ambar Mehrotra <ambar.prince@gmail.com>wrote:
How do i get the RGB value of a pixel ? I am using 'misc.imread' module of 'SciPy' to load the image file. When i type :
myimage[x,y]
It gives me a single value. What value is this exactly? And how do i get the exact RGB value of the pixel?
Hi Ambar, Grayscale images are (typically) represented as 2D arrays (height x width), and RGB images are represented by 3D arrays (height x width x color channels). The fact that you get a single value means that you're working with a grayscale image. The equivalent RGB value would be that same value repeated 3 times. If you want to force your image into RGB, you can write: from skimage import color rgb_image = color.gray2rgb(myimage) As mentioned above, this will just repeat the values of the grayscale image in the 3rd dimension. If you have questions about the numerical values, you might want to take a look at the following: http://scikit-image.org/docs/0.9.x/user_guide/data_types.html BTW, since this is the scikit-image list, I'm going to encourage you to use `skimage.io.imread`. In many cases this will probably be equivalent to SciPy's `imread`, but there are some fixes in scikit-image that probably haven't made it to SciPy (e.g. reading paletted images). Cheers, -Tony
participants (2)
-
Ambar Mehrotra
-
Tony Yu