ImageMagick仅转换灰色着色模糊

ImageMagick仅转换灰色着色模糊,imagemagick,Imagemagick,我想把任何浅色的灰色转换成白色。我使用的是'-fuzz 10%-填充白色-不透明#efeaee'。问题是模糊会转换除灰色以外的其他颜色,而不仅仅是灰色(即浅黄色和浅绿色会被转换)。我已经尝试过减少各种灰色版本的模糊和重复,但它确实不起作用,我相信有更好的方法吗?您可以在ImageMagick中通过转换到HSV颜色空间来实现这一点。然后设置S和V通道的阈值。您需要将低饱和度和高值组合为遮罩。然后使用遮罩混合输入和白色图像 非常感谢。这看起来很完美,但我无法在Powershell中进行这种类型

我想把任何浅色的灰色转换成白色。我使用的是'-fuzz 10%-填充白色-不透明#efeaee'。问题是模糊会转换除灰色以外的其他颜色,而不仅仅是灰色(即浅黄色和浅绿色会被转换)。我已经尝试过减少各种灰色版本的模糊和重复,但它确实不起作用,我相信有更好的方法吗?

您可以在ImageMagick中通过转换到HSV颜色空间来实现这一点。然后设置S和V通道的阈值。您需要将低饱和度和高值组合为遮罩。然后使用遮罩混合输入和白色图像



非常感谢。这看起来很完美,但我无法在Powershell中进行这种类型的转换?我已经做了许多其他(更简单)的转换,但无法解决如何处理上面建议中的()或/?Windows语法不同。从中删除\和。将\更改为^。后者是新行字符。因此命令需要在新的行中。否则,请删除\并将命令全部设置为一行。还要注意,.bat文件中的%需要加倍(转义)为%%。我不知道这在powershell中是如何工作的是的,我已经在bat脚本中完成了这一切,我应该能够将其放入powershell中。是双%%打破了它。非常感谢。以下是BAT文件,但在Powershell中使用“cmd.exe/c”magick convert“9.jpg”^(-clone 0-fill white-colorize 100)^(-clone 0-colorspace HSV-channel 1-separate+channel-threshold 3%%-negate)^时,其工作原理完全相同(-clone 0-色彩空间HSV-通道2-分离+通道-否定-阈值30%%-否定)^(-clone 2,3-合成倍增-合成-模糊0x1)-删除2,3-合成叠加-合成“9-out.jpg”
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.