0

For a given image, if I read it using imread, will the values in the three channels be in the range of [0,255]? If I transfer this image using rgb2gray, will the value be in the range of [0,1]?

based on the skimage doc, the calculation of rgb2gray is

Y = 0.2125 R + 0.7154 G + 0.0721 B

It seems to me that it cannot guarantee the result of rgb2gray will always belong to [0,1]. This is a bit confused.

user297850
  • 7,705
  • 17
  • 54
  • 76
  • 1
    maybe i'm missing something but grayscale is [0, 255] as well, isn't it? where 0 is black and 255 is pure white? in which case the conversion will belong to [0, 255], because 0.2125 + .7154 + .0721 = 1. – swaggy p Nov 26 '19 at 20:55

1 Answers1

1

Images in scikit-image are converted to the range [0, 1] when they are converted to floating point (ie non-integer) types. So the pipeline in rgb2gray is to first divide by 255, then multiply by that formula. For more information, see this page:

https://scikit-image.org/docs/dev/user_guide/data_types.html

Juan
  • 5,433
  • 21
  • 23