Merging layers, recovering original tones
Posted: 2011-01-11T09:05:46-07:00
I have been thinking about how best to explain this problem... it isn't a problem with ImageMagick on the command line, but more a problem of how best to *use* ImageMagick... I'm afraid I've run out of ideas about how to approach the problem due to a lack of experience
Please allow me to briefly describe a *simplification* of the scenario which I hope captures the salient points:
Imagine a glass plate (PG) which is not perfectly transparent, will have reflections on it, may be smoked glass etc. (i.e. not necessarily uniform).
This plate PG is held above two adjacent surfaces (S1) and (S2) (aligned centrally between them, and photographed. Visually in ASCI : [BLUE |Glass ][ Glass| GREEN]
The surfaces are for "chromakey" i.e. maximum Blue and maximum Green.
I have an Image mask for the area which PG covers, lets call this IM. Using this I can extract just the PG part of the picture.
I would now like to render a new image which shows PG above S1' and S2' where S1' is now Red (not Blue) and S2' is now White (not Green). To do this I take the masked part of PG and layer it on top of the new S1 and S2.
Naturally, I now have a Blue and Green looking glass plate surrounded by Red and White... so the goal is to remove the Blue and Green from the masked part of PG, whilst probably applying some transparency on it.. so that when I place it on S1' and S2' it looks correct (i.e. you see the Red/White distored by the non-perfect transparency of the glass).
When I try to set the Blue colour to transparent, and then the Green colour to transparent in the masked image ... the glass plate does layer nicely on S1' and S2' but it has a strange yellow tinge.. try as I might I can't find a solution in that direction (which sort of doesn't surprise me because if you remove the blue/green channels how can you get back to a "grey" like appearance?).
If on the other hand, I try to use combinations of difference operators, or subtraction, I can't get any closer to my end result.
I'm totally lacking the relevant sense of theory... and after reading through a LOT of ImageMagick examples, I'm still not finding my way...
Is this possible, or is information about the inherent "transparency" of the glass simply being lost through the taking of a photo (which lacks that transparency information) such that it can't be reconstructed in anyway?
I'm sorry this is such a long problem description... it just shows that I don't really understand the problem myself!
Bottom line : Is something like this at all possible?
Please allow me to briefly describe a *simplification* of the scenario which I hope captures the salient points:
Imagine a glass plate (PG) which is not perfectly transparent, will have reflections on it, may be smoked glass etc. (i.e. not necessarily uniform).
This plate PG is held above two adjacent surfaces (S1) and (S2) (aligned centrally between them, and photographed. Visually in ASCI : [BLUE |Glass ][ Glass| GREEN]
The surfaces are for "chromakey" i.e. maximum Blue and maximum Green.
I have an Image mask for the area which PG covers, lets call this IM. Using this I can extract just the PG part of the picture.
I would now like to render a new image which shows PG above S1' and S2' where S1' is now Red (not Blue) and S2' is now White (not Green). To do this I take the masked part of PG and layer it on top of the new S1 and S2.
Naturally, I now have a Blue and Green looking glass plate surrounded by Red and White... so the goal is to remove the Blue and Green from the masked part of PG, whilst probably applying some transparency on it.. so that when I place it on S1' and S2' it looks correct (i.e. you see the Red/White distored by the non-perfect transparency of the glass).
When I try to set the Blue colour to transparent, and then the Green colour to transparent in the masked image ... the glass plate does layer nicely on S1' and S2' but it has a strange yellow tinge.. try as I might I can't find a solution in that direction (which sort of doesn't surprise me because if you remove the blue/green channels how can you get back to a "grey" like appearance?).
If on the other hand, I try to use combinations of difference operators, or subtraction, I can't get any closer to my end result.
I'm totally lacking the relevant sense of theory... and after reading through a LOT of ImageMagick examples, I'm still not finding my way...
Is this possible, or is information about the inherent "transparency" of the glass simply being lost through the taking of a photo (which lacks that transparency information) such that it can't be reconstructed in anyway?
I'm sorry this is such a long problem description... it just shows that I don't really understand the problem myself!
Bottom line : Is something like this at all possible?