【问题标题】:ImageMagick convert grey shading only fuzzImageMagick 仅转换灰色阴影模糊
【发布时间】:2021-03-06 01:59:19
【问题描述】:

我想将任何浅灰色调转换为白色。我正在使用'-fuzz 10% -fill white -opaque #efeaee'。问题是绒毛会转换灰色以外的其他颜色,而不仅仅是灰色阴影(即浅黄色和浅绿色被转换)。我已经尝试减少模糊并重复各种版本的灰色,但它确实不起作用,我确定有更好的方法吗?

【问题讨论】:

    标签: imagemagick


    【解决方案1】:

    您可以在 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.
    

    【讨论】:

    • 谢谢。这看起来很完美,但我无法让这种类型的转换在 Powershell 中工作?我已经进行了许多其他(更简单)的转换,但无法弄清楚如何处理您上面建议中的 () 或 /?
    • Windows 语法不同。从 ( 和 ) 中删除 \。将 \ 更改为 ^。后者是换行符。所以命令需要换行。否则,删除 \ 并将命令全部设为一行。另请注意,.bat 文件中的 % 需要加倍(转义)为 %%。我不知道它在 Powershell 中是如何工作的
    • 是的,一切都可以在我应该能够放入 powershell 的 bat 脚本中运行。破坏它的是双%%。谢谢!!
    • 供将来参考,以下是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 -colorspace HSV -channel 2 -separate +channel -negate -t​​hreshold 30%% -negate ) ^ ( -clone 2,3 -compose multiply -composite -blur 0x1 ) -delete 2,3 -compose over -composite "9-out.jpg"
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-05-22
    • 2017-11-17
    • 2020-12-03
    • 1970-01-01
    • 1970-01-01
    • 2020-05-06
    • 1970-01-01
    相关资源
    最近更新 更多