0

In scikit-image, there two functions, img_as_float and rgb2gray. Are they generating the same type of numerical arrays, with value of [0,1]? What are the real difference of these two functions from the underlying numpy arrays used to representing a image?

user288609
  • 12,465
  • 26
  • 85
  • 127

1 Answers1

0

They do different things: img_as_float converts an image from any type to a floating point type in [0, 1], whether it is a color image or not. For example, a (512, 512) image containing uint8 values in the range 0-255 will be converted to a (512, 512) image containing float64 values in the range 0-1. See image data types and what they mean for more information.

rgb2gray converts an image from having 3 colors (red, green, and blue) in the final axis to one with one less axis and only intensity information, according to this luminance formula. The reason you might be confusing this with img_as_float is that rgb2gray calls img_as_float on its input, before converting to grayscale. So a (512, 512, 3) uint8 image with values in 0-255 will be automatically converted to a (512, 512, 3) float64 image with values in 0-1, and then the luminance formula will be applied to obtain a (512, 512) image of float64 values in 0-1.

Juan
  • 5,433
  • 21
  • 23