ImageMagick - 部分伽玛校正
ImageMagick - partial gamma correction
我有一张 RGB 图像,我想 select 对红色、绿色和蓝色的前 n% 进行伽玛校正,同时保持其他像素不变。
如何在 Linux 上使用 6.7.8-9 版的 ImageMagick 执行此操作?
我建议用 ImageMagick 的 FX.
隔离有问题的像素
正如 Mark 在评论中指出的那样,我们并不真正理解以下要求。
select the first n% of red, green and blue
这可能意味着什么。我猜你的目标是低值,或低像素强度。我将为后者举一个例子;对我来说,这对于在动态范围较差的图像上调整 Gamma 更有意义。
给定一张具有随机 n%
值的图像。
convert -size 250x250 plasma: plasma.png
通过隔离要定位的像素来创建图像遮罩,并使它们 WHITE
。使用 BLACK
作为要忽略的像素。
convert plasma.png -fx 'intensity<0.4?1:0' -blur 1x3 mask.png
# Or use threshold, as pointed out in the comments.
convert plasma.png -threshold 40% -negate -blur 1x3 mask.png
使用给定的图像,克隆它并应用伽玛校正。使用先前生成的蒙版设置 alpha/transparency,并在原始图像上合成。
convert plasma.png \( \
+clone -gamma 1.6 \
-compose copy_opacity mask.png -composite \
\) \
-compose ATop -composite output.png
我有一张 RGB 图像,我想 select 对红色、绿色和蓝色的前 n% 进行伽玛校正,同时保持其他像素不变。
如何在 Linux 上使用 6.7.8-9 版的 ImageMagick 执行此操作?
我建议用 ImageMagick 的 FX.
隔离有问题的像素正如 Mark 在评论中指出的那样,我们并不真正理解以下要求。
select the first n% of red, green and blue
这可能意味着什么。我猜你的目标是低值,或低像素强度。我将为后者举一个例子;对我来说,这对于在动态范围较差的图像上调整 Gamma 更有意义。
给定一张具有随机 n%
值的图像。
convert -size 250x250 plasma: plasma.png
通过隔离要定位的像素来创建图像遮罩,并使它们 WHITE
。使用 BLACK
作为要忽略的像素。
convert plasma.png -fx 'intensity<0.4?1:0' -blur 1x3 mask.png
# Or use threshold, as pointed out in the comments.
convert plasma.png -threshold 40% -negate -blur 1x3 mask.png
使用给定的图像,克隆它并应用伽玛校正。使用先前生成的蒙版设置 alpha/transparency,并在原始图像上合成。
convert plasma.png \( \
+clone -gamma 1.6 \
-compose copy_opacity mask.png -composite \
\) \
-compose ATop -composite output.png