0

When I look at imread function in skimage.io, it doesn't say what calculation is used when as_grey=True is set, is there a way to find the calculation going on behind the scenes?

Link to lib: (http://scikit-image.org/docs/dev/api/skimage.io.html#skimage.io.imread)

Text from link above: as_grey : bool If True, convert color images to grey-scale (64-bit floats). Images that are already in grey-scale format are not converted.

Example: RGB - [108 123 128]

When I use convert('L'), it gets converted to 119 and that's inline with the formula on this post How can I convert an RGB image into grayscale in Python? But when I use imread(img, as_grey = True), it gives me a value of 0.47126667, which is lower than the value if I were to divide the 119 value with the max value of pixel in that image to convert the values to 0-1 scale.

If you want to view the results, here's sample code:

from __future__ import division
from skimage.io import imread
import numpy as np

image_open = Image.open(image).convert('L')
np_image_open = np.array(image_open)
print (np_image_open[:10,0])

print (np_image_open[:10,0]/np.max(np_image_open))

image_open = imread(image, as_grey = True)
print (image_open[:10,0])

image_open = imread(image)
print (image_open[:10,0])
  • I think it just calls `skimage.color.rgb2gray` on the image. Conventions for floating point image representation can be found in the user guide. – Stefan van der Walt Oct 09 '17 at 23:58
  • thanks @StefanvanderWalt. Went through the document, pretty dense so didn't understand a lot of things but still a good read. – hyperloopfan Oct 25 '17 at 20:59

0 Answers0