使用ImageMagick转换,如何调整特定色调的饱和度? (以度为单位)
e.g。我增加了红色的饱和度(0度色调)。蓝色的颜色不会受到影响,但橙色也会稍微饱和,因为它紧挨着红色。
当然,我希望能够配置受影响的颜色宽度。
注意:请使用转换命令,而不是重定向到脚本。
PS:在 emcconville 的回答后澄清:
饱和度是渐进的:我们越接近匹配颜色,滤镜应用的越多。基本上它是在Photoshop中完成的。看截图 - 对不起它是法语,Teinte意味着Hue。您可以在底栏中查看和调整匹配颜色的范围,范围在8到90之间(和318到255),过滤器是渐进式的。
答案 0 :(得分:2)
The Color Modification guide offers a few examples
Here's an example that will drop the saturation by half if the hue is close to red (0°)
convert rose: \( +clone -modulate 100,50 \) \
-fx '(u.hue < 0.1 || u.hue > 0.9)? v : u' out.png
This works by copying the first image (+clone
), and alter the saturation (-modulate
) of the copied image. For the -fx
part, u
is the first image, and v
is the second. If the hue
of the first image matches our color, return the second image, else return the first.
Note: Red is 0°, so we need a logical OR (
||
), but if we're attempting to match another color, not overlapping zero, use the logical AND (&&
).example with blue
-fx '(u.hue < 0.69 && u.hue > 0.63) ? v : u'
The same -fx
approach can be used by calculating the linear scale -- like this answer, or here. Below is a similar (but not accurate) equation, and shows how to isolate the saturation channel.
convert rose: -colorspace HSL \
\( +clone -colorspace sRGB \
-fx '(hue < 0.1)?saturation+((1-(hue+0.1)*10%1)/10):(hue > 0.9)?saturation+(((hue-0.1) * 10)%1):saturation-(abs(0.5-hue))' \
\) \
-compose CopyGreen -composite \
-colorspace sRGB \
out.png
The -compose CopyGreen -composite
seems odd, but what that is really doing is taking the image generated with -fx
, and applying that as the second color channel (saturation).
Also experiment with -color-matrix
, -contrast-stretch
, & -linear-stretch
.