Log in

View Full Version : gradually changing Luma from left to right


gwendolien
14th July 2013, 17:57
I want to apply a luma correction to a clip which gradually changes the luma from LEFT to RIGHT.
Inspite of several attempts with masks and overlay etc. I don't seem to get there...

raffriff42
14th July 2013, 18:03
I want to apply a luma correction to a clip which gradually changes the luma from LEFT to RIGHT.
Inspite of several attempts with masks and overlay etc. I don't seem to get there...Need sample image(s). Is it Gain, Offset, Gamma or Saturation that is varying - or some combination? The images should tell us that.

gwendolien
14th July 2013, 18:15
Thanks raffriff42.
No, the problem is that the Luma in one of the clips I'm combining, is varying from left to right and i would like to correct that.

Wilbert
14th July 2013, 18:36
You need to create a mask which changes gradually from white to black. Just create and stack two clips with 1 pixel length each. Then resize to whatever width you want. You could also use GraMaMa to create it.

Guest
14th July 2013, 18:40
See here:

http://neuron2.net/winhistogram.html

The Hotspot filter may also be useful, with an appropriate mask. It would be just one way to implement Wilbert's suggestion.

Wilbert
14th July 2013, 19:01
@neuron2, i forgot about your filter. Wanna port it to AviSynth (and add the other color formats)? It looks very useful to me.

gwendolien
14th July 2013, 19:02
You need to create a mask which changes gradually from white to black. Just create and stack two clips with 1 pixel length each. Then resize to whatever width you want. You could also use GraMaMa to create it.
That's what I did so far:
I made two copies of the frame. One was darkened via ColorYUV(off_y=-10), the other lightened with ColorYUV(off_y=10) or so.
Then I made two Masks one gradually varying from 0 to 255 and the other from 255 to 0 and applied these to the two frameversions.
But then how to combine them into one again with the same averageluma but varying from left to right?

gwendolien
14th July 2013, 19:05
See here:

http://neuron2.net/winhistogram.html

The Hotspot filter may also be useful, with an appropriate mask. It would be just one way to implement Wilbert's suggestion.
THANKS neuron2, AGAIN there appear to be more usefull "niceties" developped earlier by Avisynth-intelligent people!

But trying that filter in VDub does not give me the opporunity to gradually change the Luma from left to right, if I'm right in my observations....

Guest
14th July 2013, 22:13
But trying that filter in VDub does not give me the opporunity to gradually change the Luma from left to right, if I'm right in my observations.... Didn't you see the example photo, which was dark on one side and light on the other.

Anyway, can you post at least a screenshot of your case (preferably some source video), so we can play around with solutions for you.

Guest
14th July 2013, 22:15
Wanna port it to AviSynth (and add the other color formats)? It looks very useful to me. I'd like to but not until later this year. I'm still tweaking my physics paper to be presented next month.

pandy
15th July 2013, 09:43
Blur and Bilinearresize combined should be OK for linear gradients.

For complex mask perhaps wavelet decomposition filter can be suitable - something like:
http://registry.gimp.org/node/11742

manono
15th July 2013, 10:52
I want to apply a luma correction to a clip which gradually changes the luma from LEFT to RIGHT.

Without a video or at least a picture it's hard to know exactly what you want. But I've been working on something I think is similar to what you want to do. The top left picture is a before frame. The top right picture is the mask used (converted from BMP to JPG). Make your own to fit your own requirements. The bottom picture is after applying the mask. The script used is:

A=Last
B=A.Tweak(Bright=-23,Cont=0.95,Coring=False)
Mask=ImageSource("Mask3.bmp")
Overlay(A,B,0,0,Mask)

And to give credit where credit is due, I learned how to do this from poisondeathray and jagabo. In principle it's easy, but it often helps to have someone else point out the way.

Lyris
15th July 2013, 13:13
^ That's brilliant. Sometimes I need to do shading correction this way.

gwendolien
15th July 2013, 20:10
Thanks for all responses!
I'm trying to attach 3 pictures to clarify my problem.
Basically, I have two versions of a clip, one VHS widescreen, and one Digital TV recording. I'm trying to enlarge the DTV recording with the extra left- and right-side "extra" pieces from the VHS-tape.
The "as is" clearly shows too low Luma on the left and too high Luma on the right.
The Lumaplus and Lumamin versions approximately match the adjacent DTV area.(don not emphasize that there needs to be a color correction occasionally, that is a separate story...)
What I 'm trying to construct is a VHS frame which at the left side has a certain Luma correction and another correction at its right side, both to as precisely as possible to match the adjacent DTV frame LUma.

Guest
15th July 2013, 20:38
That's not gradual. Split the frame into three clips using crop(). Apply levels() adjustment as needed to each clip. Then reassemble them with stackhorizontal().

gwendolien
15th July 2013, 21:02
Thanks Manono,

After rereading your last response and "simply" try it out, I think I've got what I was looking for,
although I do not underatnd why my attempts with overlay did not result in the right output.
I need to reread your response and the docs about Mask in combination with Overlay a couple of times I guess:
the brain isn't what it used to be....

gwendolien
16th July 2013, 20:31
That's not gradual. Split the frame into three clips using crop(). Apply levels() adjustment as needed to each clip. Then reassemble them with stackhorizontal().

Correct, but as I tried to make clear: the pictures given are from two different versions of the same clip.
I need the gradual change in Luma with respect to that of the other clip, to be corrected, so that the whole clip looks as much as possible as the other. In fact, the difference displayed here was observed after I applied HistogramAdjust to them....

gwendolien
16th July 2013, 22:07
I don't know what you are referring to, but am sorry if I caused any inconvenience to you. To me it seems that there is a misunderstanding here.
Again, my apologies.

IanB
16th July 2013, 23:01
As always post input source material. Showing us the result that is not right is useless (apart from showing what not to do) we simply are unable to help you without knowing all the variables.

What you needed to do here was :-

Post short samples of your 2 inputs that exhibit your troublesome condition. (5 seconds should do it)

Clearly explain what you want to achieve. (Combine the 2 sources to produce a wide screen result, centre from A, sides from B, fix different brightness)

Maybe post the script you have tried so far and explain what you are not satisfied with.

Patiently wait for someone to help.

Be prepared to post additional information as the problem becomes more clear.

Mug Funky
17th July 2013, 05:15
as brilliant as avisynth is, this looks like a job for resolve lite

http://www.blackmagicdesign.com/au/support/detail?sid=3948&pid=11735&os=win

it's free... and it's worth having as not so long ago this program was $75k+.

no point doing grads in avisynth because you'll find the grads moving around or disappearing between cuts. even fogging on film (which this looks like) will vary from one end of the reel to the other, and unless you're doing 1 camera roll at a time, it's going to change midway through when the next roll comes up.

resolve will do all the colour/tone fixes you'll ever need, though noise reduction is still avisynth's domain.

gwendolien
17th July 2013, 10:33
THANKS, both to IanB and Mug Funky!!
Unfortunately, Mug Funky, I'm running W7 32bit here and Resolve requires the 64bit version I'm afraid.
Certainly the Da Vinci Resolve Lite looks a very powerfull and handy tool!!!

unclescoob
17th July 2013, 20:36
Neuron, can you please post a script sample on how to split the frame, apply the filter, and stack it back in one script?

I've seen this before, but can't remember where to get the document.

IanB
17th July 2013, 23:35
ColorBars(640, 480)

Top=Crop(0,0, 640,120).SubTitle("Top")
Left=Crop(0,120, 120,240).SubTitle("Left")
Centre=Crop(120,120, 400,240).Letterbox(2,2,2,2, -1).SubTitle("Centre")
Right=Crop(520,120, 120,240).SubTitle("Right")
Bottom=Crop(0,360, 640,120).SubTitle("Bottom")

Middle=StackHorizontal(Left, Centre, Right)
StackVertical(Top, Middle, Bottom)

Guest
18th July 2013, 00:55
IanB has concisely answered the query so I defer to that.

BTW, if gwendolien would post the samples asked for, we can give precisely targeted help. I'm wondering why he won't do that.

gwendolien
22nd July 2013, 18:19
IanB has concisely answered the query so I defer to that.

BTW, if gwendolien would post the samples asked for, we can give precisely targeted help. I'm wondering why he won't do that.

There has been a misunderstanding in what I best should have supplied, apologies for that.
The answer given by manon shed the light here on the exact way Overlay functions in particular when using also the mask argument in it.
It has solved my problem. Again thanks to all who responded.
Would not know how to "survive" without your support!
If only my memory would allow me to remember more (precisely) what I learn on the way with avisynth...

ajp_anton
24th July 2013, 11:24
What if you make a clip that is the difference between the reference clip and the one you want to correct, blur the hell out of it to remove any kind of detail, and reapply to the clip you want fixed.
Maybe even do a gradually masked blur so that the edges where the clips are joined are even more alike.

martin53
24th July 2013, 16:41
gwendolien,

if you want a smooth transition over the horizontal axis of the screen between two source clips - and that is what I understand from your question - then you should prepare a picture that shows the amount of the 2nd clip as brightness and use that as a mask.
So far this is basic. Now which filters do allow you to merge two clips with the help of that mask?
Certainly Overlay, and also mt_merge from masktools v2. But Overlay is versatile.
If the operator between the two clips and the mask is not just a scaled addition, either Overlay can still help or the swiss knife mt_lutxyz is your tool. But that one is not easy to master.

gwendolien
19th August 2013, 18:05
Thanks ajp_anton and Martin53; apologies for this late response: but as stated above, the problem was solved.
To explain in more detail what I was trying to achieve:
2 clips of the same movie, one high quality 700x494 and one VHS 776x494.
The attempts were to add the extra material from the VHS on both sides of the "DVD_like" material....
I used HistogramAdjust on a version of the DVD material which was enlarged to 776x494 to adjust the colors/saturation/brightness of the VHS material with reasonble succes.
Except for the apparent horizontal brightness gradient of the HistogramAdjusted VHS material w.r.t. to the DVD material.
I am now processing the end result which indeed in the extreme left- and right-parts of the pictures do hardly show any difference between the original DVD and the extra parts being added with StackHorizontal!
Again my appreciation for yyour responses.