View Full Version : Overlay(): bright over dark picture.. maybe Masktools?
videoFred
22nd March 2007, 09:16
Hello everybody,
When transfering real film to digital, sometimes the problem is: dynamic range.
In 90% of the cases, my camera captures the entire picture fine.
But with some scenes (underexposed film etc), I must capture the picture twice.
A dark one and a bright one. I have software for this.
It's the same frame, captured twice while standing still.
So, the dimensions are 100% the same. Nothing has moved in between.
It looks like this:
dark picture:
http://users.pandora.be/ho-slotcars/Double_Cap/Doom/dark.jpg
bright picture:
http://users.pandora.be/ho-slotcars/Double_Cap/Doom/bright.jpg
and this is the overlay, opacity=0.5
http://users.pandora.be/ho-slotcars/Double_Cap/Doom/overlay.jpg
But it can be better than this, can it?
I think Masktools is what I need to do this.
I want to keep the bright picture and only replace the out of range pixels.
I have never used Masktools and I do not understand it very well :confused:
So, if someone could point me in the right direction, I would be very grateful. :)
A short 10 frames Huffyuv 1024x768 clip can be found here:
http://users.pandora.be/ho-slotcars/Double_Cap/Doom/
That clip contains frames like this: dark/bright/dark/bright etc...
This simple script will separate the dark and bright frames in to two different clips and apply the overlay:
A= avisource("double_cap_001.avi").selecteven().converttoYV12()
B= avisource("double_cap_001.avi").selectodd().converttoYV12()
C= overlay(A,B,mode="blend",opacity=0.5)
C
But, again, I bet Masktools will do a better job....
Fred.
foxyshadis
22nd March 2007, 10:49
Hey, true HDR. =D
mt_lutxy(dark, bright, "x 32 < x 4 * y 224 > 256 256 y - 4 * - 128 ? ?")
It makes a mask that's mostly a 50/50, but in the darkest parts prefer the light and in the brightest prefer the dark. I don't think it'll work great, it totally won't work for color, but it's something to start with....
I'm sure there's a lot of literature on how to make a real HDR merge out there, though, and this is just a test until someone who knows better shows up. ;)
videoFred
22nd March 2007, 12:35
Thank you for the hint..:)
I must use it as a mask...
I post a result here.
It gives me this:
http://users.pandora.be/ho-slotcars/Double_Cap/Doom/mt_lutxy.jpg
As you see, sharpness is a lot better :)
I used this script:
Loadplugin("mt_masktools.dll")
A= avisource("double_cap_001.avi").bicubicresize(512,384).selecteven().converttoYV12()
B= avisource("double_cap_001.avi").bicubicresize(512,384).selectodd().converttoYV12()
E= mt_lutxy(A,B, "x 32 < x 4 * y 224 > 256 256 y - 4 * - 128 ? ?")
F= overlay(A,B,mask=E,mode="blend",opacity=1.0)
F
But I still use overlay()...
It must be possible to do the overlay itself with Masktools, right?
Fred.
Mug Funky
22nd March 2007, 13:02
would there be a problem with the characteristics of the different film prints? if the images aren't perfectly linear there'd be distortions wouldn't there?
btw, the Arriscan film scanner has a 2-flash mode for just this purpose... i only wish i could run my stills through it.
videoFred
22nd March 2007, 13:09
would there be a problem with the characteristics of the different film prints? if the images aren't perfectly linear there'd be distortions wouldn't there?
The difference between the frames is the shutter speed of the camera. In this case, it was 1/32 and 1/256.
Now, if there would be a problem, what can we do about that? Correction before overlaying?
PS: I have used the same camera settings fror both capturings.. only the shutter speed was different. White balance was fixed on the bright picture. And backlight was of cource the same, too.
Fred.
G_M_C
22nd March 2007, 15:25
What if you take the dark picture and use HDRAGC() on it with higher gain and corrector values combined with protector=0. You might be able to "simulate" the lighter picture out of the darker one.
If you overlay that picture and THAN overlay it on the dark picture with opacity 66% the results might be similar to what you are doing now, but circumventing the shutter-problem.
(i know; Lot of "might be's" in my post, but i'm @ work and cant actually test now, and assuming the shutter-speed difference actually leeds to a problem in the first place ;) ).
Mug Funky
23rd March 2007, 05:35
hmm. i did something similar in photoshop the other day, but haven't got it down pat yet.
try:
- brighten the dark picture so the highlights are where you want them. (levels() in avs)
- create a mask of the overexposed picture that masks off the highlights. make sure all that cyan blowout on the left side wall is in this mask. this can be done with levels again, and probably throw a greyscale after it.
- darken the overexposed pic so that the darker areas match the newly brightened underexposed pic as closely as possible.
- overlay the brightened dark pic and the darkened bright pic (hehe, english rocks), and use the mask you made to softly blend between good parts of both images. you should be able to use overlay(clip1,clip2,mask=clip1mask). use invert on the mask if you need to, or just swap the order of the inputs to overlay.
hope that works. i haven't tried it :)
the hard part will be matching the colour balance and gammas, etc on the light and dark pics. this is where having nonlinear response really sucks - if it were all perfectly linear there'd be no need to correct anything. it's a shame avisynth can't do 3D lookup tables - that'd rock unbelievable hard, and solve the "film look" problems pretty definitively.
the good thing is once you've got it right for this, in theory you should be able to apply it to other stuff captured at the same settings.
[edit] this is not quite on topic, but i used this approach to save a badly overexposed digital photo - because it was shot under incandescent light, the blue channel had the full range of highlights where the red channel was completely crushed. i patched blue over red to restore the highlights, then converted to black and white because i didn't know if the colours would be pwned by this or not.
videoFred
23rd March 2007, 09:16
@ Mug Funky:
Thank you for the suggestions!
I Think I have found it...:)
First, the bright picture contains the best color info.
So, we overlay the dark one over the bright one.
For the mask we use.... the bright picture itself!
It works best if we tweak levels a bit on both pictures before overlaying like you suggested. :)
http://users.pandora.be/ho-slotcars/Double_Cap/Doom/overlay_001.jpg
D= overlay(B,A,mode="blend",opacity=0.8,mask=B)
Simple, hug? :cool:
Fred.
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.