【发布时间】:2021-03-06 01:59:19
【问题描述】:
我想将任何浅灰色调转换为白色。我正在使用'-fuzz 10% -fill white -opaque #efeaee'。问题是绒毛会转换灰色以外的其他颜色,而不仅仅是灰色阴影(即浅黄色和浅绿色被转换)。我已经尝试减少模糊并重复各种版本的灰色,但它确实不起作用,我确定有更好的方法吗?
【问题讨论】:
标签: imagemagick
我想将任何浅灰色调转换为白色。我正在使用'-fuzz 10% -fill white -opaque #efeaee'。问题是绒毛会转换灰色以外的其他颜色,而不仅仅是灰色阴影(即浅黄色和浅绿色被转换)。我已经尝试减少模糊并重复各种版本的灰色,但它确实不起作用,我确定有更好的方法吗?
【问题讨论】:
标签: imagemagick
您可以在 ImageMagick 中通过转换为 HSV 颜色空间来做到这一点。然后阈值 S 和 V 通道。您希望将低饱和度和高值组合为蒙版。然后使用遮罩混合输入和白色图像。
sthresh=10
vthresh=10
convert zelda1.jpg \
\( -clone 0 -fill white -colorize 100 \) \
\( -clone 0 -colorspace HSV -channel 1 -separate +channel -threshold $sthresh% -negate \) \
\( -clone 0 -colorspace HSV -channel 2 -separate +channel -negate -threshold $vthresh% -negate \) \
\( -clone 2,3 -compose multiply -composite -blur 0x1 \) \
-delete 2,3 \
-compose over -composite \
result.png
sthresh is the fuzz value for how close in color it is to white
vthresh is the fuzz value for how close it is in brightness to white
Values of zero mean exactly pure white.
【讨论】: