ImageMagick 中的灰卡颜色平衡
Grey Card color balancing in ImageMagick
我正在尝试使用 ImageMagick 实现 Adobe Lightroom 的灰卡色彩平衡。我从 ImageMagick 那里得到了一些使用灰卡平衡颜色的信息:-
convert MAIN.JPG ^
( +clone ( REFERENCE.JPG -gravity Center -crop "128x128+0+0" -scale "1x1" -negate ) +dither -interpolate Integer -clut ) ^
-compose Overlay -composite ^
FIXED.JPG
我试过这个,但结果与 Lightroom 不同。谁能告诉我为什么这不准确以及如何获得与在 Lightroom 中相同的结果?
图片如下:-
原一个:-
使用 Lightroom 进行平衡:-
使用 ImageMagick 进行平衡:-
我已经在 http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=32473#p148599 的 Imagemagick Discourse 服务器上详细回答了这个问题。解决方法如下,在RGB(而不是sRGB)模式下使用-color-matrix
infile="8Mvyi.jpg"
gray=0.5
declare `convert "$infile" -colorspace RGB -crop 90x40+106+208 +repage -format "rratio=%[fx:$gray/mean.r]\ngratio=%[fx:$gray/mean.g]\nbratio=%[fx:$gray/mean.b]\n" info:`
convert "$infile" -colorspace RGB -color-matrix \
"$rratio 0 0 \
0 $gratio 0 \
0 0 $bratio" -colorspace sRGB result3.jpg
正如我在评论中提到的,您可以尝试另一种线性颜色 space 和其他灰度值,直到它们匹配为止。在 Imagemagick 中,我将中灰度值更改为 .466 并尝试了 RGB 和 XYZ colorspaces.
infile="8Mvyi.jpg"
gray=0.466
declare `convert "$infile" -colorspace RGB -crop 90x40+106+208 +repage -format "rratio=%[fx:$gray/mean.r]\ngratio=%[fx:$gray/mean.g]\nbratio=%[fx:$gray/mean.b]\n" info:`
echo "$rratio $gratio $bratio"
convert "$infile" -colorspace RGB -color-matrix \
"$rratio 0 0 \
0 $gratio 0 \
0 0 $bratio" -colorspace sRGB result3a.png
infile="8Mvyi.jpg"
gray=0.466
declare `convert "$infile" -colorspace XYZ -crop 90x40+106+208 +repage -format "rratio=%[fx:$gray/mean.r]\ngratio=%[fx:$gray/mean.g]\nbratio=%[fx:$gray/mean.b]\n" info:`
echo "$rratio $gratio $bratio"
convert "$infile" -colorspace XYZ -color-matrix \
"$rratio 0 0 \
0 $gratio 0 \
0 0 $bratio" -colorspace sRGB result3b.png
两者都不符合您的 Lightroom 图片。所以我只能建议使用这两种颜色 space 并调整中间灰度值,直到获得尽可能接近的匹配。
我正在尝试使用 ImageMagick 实现 Adobe Lightroom 的灰卡色彩平衡。我从 ImageMagick 那里得到了一些使用灰卡平衡颜色的信息:-
convert MAIN.JPG ^
( +clone ( REFERENCE.JPG -gravity Center -crop "128x128+0+0" -scale "1x1" -negate ) +dither -interpolate Integer -clut ) ^
-compose Overlay -composite ^
FIXED.JPG
我试过这个,但结果与 Lightroom 不同。谁能告诉我为什么这不准确以及如何获得与在 Lightroom 中相同的结果?
图片如下:-
原一个:-
使用 Lightroom 进行平衡:-
使用 ImageMagick 进行平衡:-
我已经在 http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=32473#p148599 的 Imagemagick Discourse 服务器上详细回答了这个问题。解决方法如下,在RGB(而不是sRGB)模式下使用-color-matrix
infile="8Mvyi.jpg"
gray=0.5
declare `convert "$infile" -colorspace RGB -crop 90x40+106+208 +repage -format "rratio=%[fx:$gray/mean.r]\ngratio=%[fx:$gray/mean.g]\nbratio=%[fx:$gray/mean.b]\n" info:`
convert "$infile" -colorspace RGB -color-matrix \
"$rratio 0 0 \
0 $gratio 0 \
0 0 $bratio" -colorspace sRGB result3.jpg
正如我在评论中提到的,您可以尝试另一种线性颜色 space 和其他灰度值,直到它们匹配为止。在 Imagemagick 中,我将中灰度值更改为 .466 并尝试了 RGB 和 XYZ colorspaces.
infile="8Mvyi.jpg"
gray=0.466
declare `convert "$infile" -colorspace RGB -crop 90x40+106+208 +repage -format "rratio=%[fx:$gray/mean.r]\ngratio=%[fx:$gray/mean.g]\nbratio=%[fx:$gray/mean.b]\n" info:`
echo "$rratio $gratio $bratio"
convert "$infile" -colorspace RGB -color-matrix \
"$rratio 0 0 \
0 $gratio 0 \
0 0 $bratio" -colorspace sRGB result3a.png
infile="8Mvyi.jpg"
gray=0.466
declare `convert "$infile" -colorspace XYZ -crop 90x40+106+208 +repage -format "rratio=%[fx:$gray/mean.r]\ngratio=%[fx:$gray/mean.g]\nbratio=%[fx:$gray/mean.b]\n" info:`
echo "$rratio $gratio $bratio"
convert "$infile" -colorspace XYZ -color-matrix \
"$rratio 0 0 \
0 $gratio 0 \
0 0 $bratio" -colorspace sRGB result3b.png
两者都不符合您的 Lightroom 图片。所以我只能建议使用这两种颜色 space 并调整中间灰度值,直到获得尽可能接近的匹配。