Unpremultiply Alpha #5074
Replies: 7 comments 1 reply
-
"Premultiply" means that before an image operation that mixes pixels from different images, the image pixels are multiplied by alpha. After the image operation, pixels are divided by alpha. Montage doesn't mix pixels from multiple images, so I don't see how premultiply can make a difference. But you can of course, multiply RGB values by alpha values, if you want:
|
Beta Was this translation helpful? Give feedback.
-
I suggest you post your input images. |
Beta Was this translation helpful? Give feedback.
-
In your image, which I have called hair.png, the strands with transparency are darker than opaque hair. Perhaps the original photo (or 3D ray-tracer) had a dark background. We can make pixels with transparency lighter by dividing all pixels by their alpha. We can divide by the extracted alpha. This would remove the alpha, so we CopyOpacity to restore it. Windows BAT syntax.
If it was made by a ray-tracer, it should be told to make a transparent background. If it makes an opaque background, and you know what that background is, the hair colours can be reconstructed accurately. See Watermarks, which addresses exactly that problem, |
Beta Was this translation helpful? Give feedback.
-
Thanks for the help @snibgo. Here's the original and the one processed as you suggested above: It's getting there but there's still some darkening for some reason. I'm struggling to see what the difference is in the processing between the two. |
Beta Was this translation helpful? Give feedback.
-
I don't know what Fusion does. The method I showed makes the semi-transparent hair pixels roughly the same colour and lightness as nearby opaque hair colours. When flattened against white, they become even more lighter. If you want them lighter still, doing the division in linear RGB space will do that:
|
Beta Was this translation helpful? Give feedback.
-
with ImageMagick 7 :
|
Beta Was this translation helpful? Give feedback.
-
I'm trying to do something like
magick montage -mode concatenate -tile 1.png 2.png 3.png -background "white" out.png
Where
1.png
2.png
3.png
are have a premultiplied alpha.However, the resulting out.png has dark fringing
But as you can see in the attached images, if I unpremult the image in a compositing app then it looks fine
Can I unpremultiply the images when creating the montage?
Beta Was this translation helpful? Give feedback.
All reactions