Imagemagick:分离/合并操作后通道变亮

huangapple go评论45阅读模式
英文:

Imagemagick: channel gets lighter after separate/combine operation

问题

以下是您要翻译的内容:

I'm trying to combine PBR normal/roughness/metallic map images (.png) into a single RGBA image (also .png), with the normal map in the red and green channels, the roughness map in the blue channel, and the metallic map in the alpha channel.

The following bash command line works, but for some reason the green channel is slightly lighter in the composite image than it is in the original normal image (e.g. a value of 0x7e in the original is raised to 0x87 in the composite). All three other channels keep their original values. If I switch the order of the red and green separation, it's the red channel in the final image that gets lighter. What could be causing that, and how do I avoid it?

convert ImageName_Normal.png -colorspace sRGB -write mpr:NORMAL_R -channel R -separate +channel \
-write mpr:NORMAL_G -channel G -separate +channel +delete \
ImageName_Roughness.png -colorspace Gray -flatten -write mpr:ROUGHNESS +delete \
ImageName_Metallic.png -colorspace Gray -flatten -write mpr:METALLIC +delete \
mpr:NORMAL_G mpr:NORMAL_R mpr:ROUGHNESS -combine -write mpr:RGBCOMP +delete \
mpr:RGBCOMP mpr:METALLIC -alpha off -compose Copy_Opacity -composite -depth 8 \
png32:ImageName_NormRoughMetal.png

ImageMagick version is 6.9.11-60

I tried different variations on it - using \( +clone, another copy of the normal map (with and without +delete after the first one), and so on. None of them worked any better (and some actually gave me two copies of the normal map's red channel even though green was specified on the command line for the second one).

英文:

I'm trying to combine PBR normal/roughness/metallic map images (.png) into a single RGBA image (also .png), with the normal map in the red and green channels, the roughness map in the blue channel, and the metallic map in the alpha channel.

The following bash command line works, but for some reason the green channel is slightly lighter in the composite image than it is in the original normal image (e.g. a value of 0x7e in the original is raised to 0x87 in the composite). All three other channels keep their original values. If I switch the order of the red and green separation, it's the red channel in the final image that gets lighter. What could be causing that, and how do I avoid it?

convert ImageName_Normal.png -colorspace sRGB -write mpr:NORMAL_R -channel R -separate +channel \
-write mpr:NORMAL_G -channel G -separate +channel +delete \
ImageName_Roughness.png -colorspace Gray -flatten -write mpr:ROUGHNESS +delete \
ImageName_Metallic.png -colorspace Gray -flatten -write mpr:METALLIC +delete \
mpr:NORMAL_G mpr:NORMAL_R mpr:ROUGHNESS -combine -write mpr:RGBCOMP +delete \
mpr:RGBCOMP mpr:METALLIC -alpha off -compose Copy_Opacity -composite -depth 8 \
png32:ImageName_NormRoughMetal.png

ImageMagick version is 6.9.11-60

I tried different variations on it - using \( +clone , another copy of the normal map (with and without +delete after the first one), and so on. None of them worked any better (and some actually gave me two copies of the normal map's red channel even though green was specified on the command line for the second one).

答案1

得分: 0

I do not think your command is what you want in Imagemagick. I think you are not keeping the first two parts properly separate.

尝试这个命令:

convert TestImage_Normal.png -colorspace sRGB -write mpr:NORMAL +delete \
\( mpr:normal -channel R -separate +channel -write mpr:NORMAL_R +delete \) \
\( mpr:normal -channel G -separate +channel -write mpr:NORMAL_G +delete \) \
\( TestImage_Roughness.png -colorspace Gray -flatten -write mpr:ROUGHNESS +delete \) \
\( TestImage_Metallic.png -colorspace Gray -flatten -write mpr:METALLIC +delete \) \
\( mpr:NORMAL_G mpr:NORMAL_R mpr:ROUGHNESS -combine -write mpr:RGBCOMP +delete \) \
mpr:RGBCOMP mpr:METALLIC -alpha off -compose Copy_Opacity -composite -depth 8 \
png32:TestImage_NormRoughMetal_fred.png

请注意,代码部分没有翻译。

英文:

I do not think your command is what you want in Imagemagick. I think you are not keeping the first two parts properly separate.

Try this

convert TestImage_Normal.png -colorspace sRGB -write mpr:NORMAL +delete \
\( mpr:normal -channel R -separate +channel -write mpr:NORMAL_R +delete \) \
\( mpr:normal -channel G -separate +channel -write mpr:NORMAL_G +delete \) \
\( TestImage_Roughness.png -colorspace Gray -flatten -write mpr:ROUGHNESS +delete \) \
\( TestImage_Metallic.png -colorspace Gray -flatten -write mpr:METALLIC +delete \) \
\( mpr:NORMAL_G mpr:NORMAL_R mpr:ROUGHNESS -combine -write mpr:RGBCOMP +delete \) \
mpr:RGBCOMP mpr:METALLIC -alpha off -compose Copy_Opacity -composite -depth 8 \
png32:TestImage_NormRoughMetal_fred.png

huangapple
  • 本文由 发表于 2023年2月10日 10:19:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/75406346.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定