本文介绍了关于imread和rgb2gray的数组值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
对于给定的图像,如果我使用imread读取图像,则三个通道中的值是否会在[0,255]的范围内?如果我使用rgb2gray传输此图像,该值是否在[0,1]范围内?
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
在我看来,这不能保证rgb2gray的结果将始终属于[0,1].这有点困惑.
推荐答案
当scikit-image中的图像转换为浮点(即非整数)类型时,它们将转换为[0,1]范围.因此,rgb2gray中的管道首先要除以255,然后再乘以该公式.有关更多信息,请参阅此页面:
https://scikit-image.org/docs/dev/user_guide/data_types.html
这篇关于关于imread和rgb2gray的数组值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!