【发布时间】:2020-10-01 20:53:02
【问题描述】:
我遇到了一个函数的两个代码示例 sn-ps,它们声称分解图像并返回仅具有色调、仅饱和度和仅值的图像,具体取决于作为参数传递的颜色。
def break_down(image, channel):
hsv = color.rgb2hsv(image)
if (channel == "H"):
out = hsv[:, :, 0].copy()
if (channel == "S"):
out = hsv[:, :, 1].copy()
if (channel == "V"):
out = hsv[:, :, 2].copy()
return out
def break_down(image, channel):
hsv = color.rgb2hsv(image)
out = hsv.copy()
if (channel == "H"):
out[:, :, 1] = 0
out[:, :, 2] = 0
if (channel == "S"):
out[:, :, 0] = 0
out[:, :, 2] = 0
if (channel == "V"):
out[:, :, 0] = 0
out[:, :, 1] = 0
return out
第一个输出为彩色图像(红/绿/蓝)。但是,第二个提供黑色/白色/灰色阴影的输出。我无法理解哪个是正确的代码。可能没有一个是准确的。
从逻辑上讲,例如,当我们只显示饱和度时会发生什么?如果 Hue 是图像的颜色分量,那么返回的图像应该是没有颜色的吧?
【问题讨论】:
标签: python machine-learning computer-vision rgb hsv