These are always good.HugoRune wrote:Some random thoughts
It like a 'box of chocolates' as the saying goes.
I have added a note about this, (now uploaded, should appear real soon).the -auto-level works if the overlay contains areas of total transparency and total opacity
I have also added a second 'full example' with the simplifications when only black and white backgrounds are involved.
yes it is. I would like to see the -fx handling re-written in many ways. That is one of them. That is some values get cached when they are constant.So instead of -auto-level -negate
-fx "u/maxima" -negate
(this command takes rather long to execute, I think imagemagick is calculating maxima for every pixel.
I should warn you. One of my firsts tests with using u.p{0,0} failed.Alternatively, I just realized, with your formula:Sa = 1 - (Rc1 - Rc2)/(Dc1-Dc2)Code: Select all
convert match_burn_skyblue.png match_burn_gold.png -fx "1 - (u-v)/(u.p{0,0}-v.p{0,0}) match_alpha.png
I wanted to reduce the number of images, so after I had the alpha, I added it immediatally to the original image. It sort of simplified and removed the needs for extra cloning. I Then tried to use the now fullytransparent p{0,0} color for the recovery step. But the results were all wrong.
Seems that u.p{0,0} returns '0' values for color channels when a pixel was fully transparent, even though non-zero values really are present in the image.
For example...
Code: Select all
convert 'xc:rgba(10%,20%,30%,0)' -fx 'debug(u)' null:
rgba(10%,20%,30%,0)[0,0].red: u=0
rgba(10%,20%,30%,0)[0,0].green: u=0
rgba(10%,20%,30%,0)[0,0].blue: u=0
Code: Select all
convert 'xc:rgba(10%,20%,30%,0)' -alpha off -fx 'debug(u)' null:
rgba(10%,20%,30%,0)[0,0].red: u=0.100008
rgba(10%,20%,30%,0)[0,0].green: u=0.2
rgba(10%,20%,30%,0)[0,0].blue: u=0.300008
Note -evaluate-sequence would not generate monocrome results. The only reason it does NOT in my use is I separated the channels and use it to get the results from the channel with the 'maximum differences' for any transparency. It still relies on the images being overlayed on solid fixed colors.to recover an overlay from a series of images with mixed unknown backgrounds (img001.png-img999.png):check whether the background area is monochrome in both outputs, and then proceed as above using maximage and minimage as input.Code: Select all
convert img*.png -evaluate-sequence max maximage.png convert img*.png -evaluate-sequence min minimage.png
In a long sequence such as a video stream (for which logo removal would be a really great feature), may not even generate ALL black and all white, though it is likely you will get a black 'minimum' image, you may not get white. I have been looking for a example for testing purposes. Also know that if the logo is opaque, you may never quite know what was underneath. but at least you can 'hole fill' to remove the opaque parts of the logo.
Still being able to extract the overlay from two 'known' backgrounds, is a great step forward. Basically as two known backgrounds is often easy to get a hold of, especially for 'GIF animations' of highly anti-alised animations you can find on the web.
All I knew was that it should have been possible, as it would provide enough known data to figure out the unknowns of original transparency and color of the overlay. I was just glad I was about to generate a reasonable test image for this purpose.