sca*_*der 3 image-manipulation imagemagick
我有以下图像:
我想要的是仅保留红色并将所有其他颜色去饱和为灰度。结果是这样的:
如何使用 Imagemagick 命令行执行此操作?
我尝试过这个但失败了:
convert original.png \( -clone 0 -transparent red -alpha extract -transparent black \) redonly.png
Run Code Online (Sandbox Code Playgroud)
这是使用 ImageMagick 的一种方法,尽管并不完美。我指定红色的色调 = 0 度,容差 = 25 度,两者都在 0 到 360 的范围内。
输入:
hue=0
tolerance=25
toler=`convert xc: -format "%[fx:(100*$tolerance/360)]" info:`
hueval=`convert xc: -format "%[fx:50-$hue]" info:`
thresh=`convert xc: -format "%[fx:100-$tolerance]" info:`
convert tomato.jpg \
\( -clone 0 -colorspace gray -colorspace sRGB \) \
\( -clone 0 -colorspace HSL -channel 0 -separate +channel \
-evaluate AddModulus ${hueval}% \
-solarize 50% -level 0x50% \
-threshold $thresh% \) \
-swap 0,1 -alpha off -compose over -composite \
result.jpg
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
527 次 |
| 最近记录: |