Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 7th June 2010, 15:16   #21  |  Link
LaTo
LaTo INV.
 
LaTo's Avatar
 
Join Date: Jun 2007
Location: France
Posts: 701
Quote:
Originally Posted by LaTo View Post
Thanks for report!

Problem with high-contrast transitions should be fixed with 1.02

And I'll add later more options to be more aggressive with smoothing
I can't reproduce it with 32bits version, I wait after your report (fixed or not?)

If it's not fixed, can you try with Smode=0...4 ?

Last edited by LaTo; 8th June 2010 at 17:50.
LaTo is offline   Reply With Quote
Old 14th June 2010, 17:02   #22  |  Link
LaTo
LaTo INV.
 
LaTo's Avatar
 
Join Date: Jun 2007
Location: France
Posts: 701
Update 2010.06.14

v1.16:
replaced Smode 3 & 4 with stronger smoothing function
changed minors things


About Smode:
Quote:
In strength order:
+ 3 > 4 >>> 1 > 2 -

In speed order:
+ 2 > 1 >>> 3 >>> 4 -

In fact, Smode=2 is a lighter&faster version of Smode=1 and Smode=4 is a better version of Smode=3 (but much slower).

Last edited by LaTo; 14th June 2010 at 17:21.
LaTo is offline   Reply With Quote
Old 19th June 2010, 14:55   #23  |  Link
carlmart
Carlos Martinez
 
Join Date: Aug 2005
Posts: 287
This filter might be handy to what I am trying to do now, which is lowering the gamma on a video I have. What I want is getting some more detail in the shadows and darker areas.

What I am not familiar with is about the synthax to combine several functions together, and perhaps set some limiting on the brighter areas.

I have already tried <SmoothLevels(gamma=1.5)> and it brings out a lot. But I wonder if combining others might get more and not make things too "milky".

Limiting brighter areas would be handy too, I think. How do I write all this so I can play with the filters in AvsP?

This is my more critical situation, where the musician on the right is too dark:

http://www.mediafire.com/file/n4w5zu...contrast#1.jpg
carlmart is offline   Reply With Quote
Old 19th June 2010, 16:50   #24  |  Link
LaTo
LaTo INV.
 
LaTo's Avatar
 
Join Date: Jun 2007
Location: France
Posts: 701
Quote:
Originally Posted by carlmart View Post
This filter might be handy to what I am trying to do now, which is lowering the gamma on a video I have. What I want is getting some more detail in the shadows and darker areas.

What I am not familiar with is about the synthax to combine several functions together, and perhaps set some limiting on the brighter areas.

I have already tried <SmoothLevels(gamma=1.5)> and it brings out a lot. But I wonder if combining others might get more and not make things too "milky".

Limiting brighter areas would be handy too, I think. How do I write all this so I can play with the filters in AvsP?

This is my more critical situation, where the musician on the right is too dark:

http://www.mediafire.com/file/n4w5zu...contrast#1.jpg
Lmode=1 should be useful for your clip:
Code:
SmoothLevels(gamma=1.6,Ecenter=32,Lmode=1)
Tweak gamma (around 2.0) for intensity and Ecenter (between 32 & 64) for best looking.
LaTo is offline   Reply With Quote
Old 21st June 2010, 19:08   #25  |  Link
VincAlastor
Registered User
 
Join Date: Sep 2009
Location: Berlin
Posts: 148
thank you lato, smoothadjust is much faster than smoothlevels!
VincAlastor is offline   Reply With Quote
Old 21st June 2010, 19:32   #26  |  Link
LaTo
LaTo INV.
 
LaTo's Avatar
 
Join Date: Jun 2007
Location: France
Posts: 701
Update 2010.06.21

v1.18:
tweaked Smode 3 & 4
updated avisynth header

LaTo is offline   Reply With Quote
Old 21st June 2010, 22:32   #27  |  Link
Blue_MiSfit
Derek Prestegard IRL
 
Blue_MiSfit's Avatar
 
Join Date: Nov 2003
Location: Los Angeles
Posts: 5,557
Nice! Your scripts are AWEOSME, LaTo! I use SmoothLevels quite frequently so any update or additional functionality is enthusiastically welcomed!

Derek
Blue_MiSfit is offline   Reply With Quote
Old 27th June 2010, 05:17   #28  |  Link
Bi11
Architect
 
Bi11's Avatar
 
Join Date: May 2010
Posts: 57
I have a video that seems to have been converted from tv->pc levels, which causes details to appear hidden in dark areas and washed-out or clipped in bright areas (think dynamic contrast).

The levels histogram is shown below:


Using SmoothLevels(preset="pc2tv") gives the histogram below:


That's probably how it was intended to look, but when viewed on a PC monitor it is clearly lacking contrast and vibrancy.
I want to keep the contrast but still see details in bright and dark areas.

I tried SmoothLevels(gamma=1.05, output_low=10, Lmode=3).SmoothTweak(contrast=0.92) giving the histogram below:


The resulting image looks good enough but I really want to map tv 0 (i.e. 16) to pc 0 and tv white (i.e. 235) to pc 255, and a few levels above and below black and white could be mapped within 0-16 and 235-255 resp.
How can I achieve that?

BTW, it would be convenient to have a "show histogram" option in your plugin.
Bi11 is offline   Reply With Quote
Old 27th June 2010, 11:06   #29  |  Link
LaTo
LaTo INV.
 
LaTo's Avatar
 
Join Date: Jun 2007
Location: France
Posts: 701
Quote:
Originally Posted by Bi11 View Post
I have a video that seems to have been converted from tv->pc levels, which causes details to appear hidden in dark areas and washed-out or clipped in bright areas (think dynamic contrast).

The levels histogram is shown below:


Using SmoothLevels(preset="pc2tv") gives the histogram below:


That's probably how it was intended to look, but when viewed on a PC monitor it is clearly lacking contrast and vibrancy.
I want to keep the contrast but still see details in bright and dark areas.

I tried SmoothLevels(gamma=1.05, output_low=10, Lmode=3).SmoothTweak(contrast=0.92) giving the histogram below:


The resulting image looks good enough but I really want to map tv 0 (i.e. 16) to pc 0 and tv white (i.e. 235) to pc 255, and a few levels above and below black and white could be mapped within 0-16 and 235-255 resp.
How can I achieve that?

BTW, it would be convenient to have a "show histogram" option in your plugin.
A sample please?
LaTo is offline   Reply With Quote
Old 27th June 2010, 23:50   #30  |  Link
Bi11
Architect
 
Bi11's Avatar
 
Join Date: May 2010
Posts: 57
I want something like:
Code:
# Compress 0-255->10-237
SmoothLevels(gamma=1.05, output_low=10, output_high=237)
# Stretch 10-16->0-16
SmoothLevels(input_low=10, input_high=16, output_low=0, output_high=16)
# Stretch 235-237->235-255
SmoothLevels(input_low=235, input_high=237, output_low=235, output_high=255)
Maybe I need to use MaskTools.
Bi11 is offline   Reply With Quote
Old 28th June 2010, 00:48   #31  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,394
That's S-curve contrast reduction, basically.

Too lazy to work out a general formula ... with fixed values to spread [0-8]>[0,16] and [247,255]>[239,255] :

Code:
mt_lut("x 8 < x 2 * x 247 > 255 255 x - 2 * - x 8 - 247 24 - 247 8 - / * 16 + ? ?",U=2,V=2)
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)

Last edited by Didée; 28th June 2010 at 01:46. Reason: Fixed error pointed out by Gavino. Thankyou.
Didée is offline   Reply With Quote
Old 28th June 2010, 01:02   #32  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,384
Quote:
Originally Posted by Didée View Post
Code:
mt_lut("x 8 < x 2 * x 247 > 255 255 x - 2 * - x 8 - 247 16 - 247 8 - / * 16 + ? ?",U=2,V=2)
I think you mean
Code:
mt_lut("x 8 < x 2 * x 247 > 255 255 x - 2 * - x 8 - 239 16 - 247 8 - / * 16 + ? ?",U=2,V=2)
Gavino is offline   Reply With Quote
Old 28th June 2010, 01:45   #33  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,394
No ... I was meaning
Code:
mt_lut("x 8 < x 2 * x 247 > 255 255 x - 2 * - x 8 - 247 8 - 8 - 8 - 247 8 - / * 16 + ? ?",U=2,V=2)
In a word, of course you're right. Thanks for pointing out.
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 28th June 2010, 02:12   #34  |  Link
Bi11
Architect
 
Bi11's Avatar
 
Join Date: May 2010
Posts: 57
Quote:
Originally Posted by Didée View Post
... with fixed values to spread [0-8]>[0,16] and [247,255]>[239,255] :

Code:
mt_lut("x 8 < x 2 * x 247 > 255 255 x - 2 * - x 8 - 247 24 - 247 8 - / * 16 + ? ?",U=2,V=2)
I tried it but there are still some light-gray details in bright areas that aren't being seen.

I don't know RPN very well, or how mt_lut should be used, but I tried:
Code:
mt_lut("x 8 < x 2 * x 252 > 255 255 x - 2 * - x 8 - 235 16 - 252 8 - / * 16 + ? ?",U=2,V=2)
It shows light-gray details while still keeping white at 255.
Original frame: Code above:

Now I would like to make the dark levels a little brighter and then smooth the levels curve overall.

Edit: Since this clip is probably supposed to look like tv levels [16,235], I should ask how to properly convert TV->PC such that the video doesn't look like dynamic contrast is turned on. Maybe something like 16-20 -> 0-16 and 233-235 -> 235-255.

Last edited by Bi11; 28th June 2010 at 02:40.
Bi11 is offline   Reply With Quote
Old 28th June 2010, 08:44   #35  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,394
Quote:
Originally Posted by Bi11 View Post
I tried it but there are still some light-gray details in bright areas that aren't being seen.
Somehow I have a suspicion. The suspicion that you are using a badly-calibrated (or badly-featured) LCD flatscreen, and that you're trying to work around bad brightlevel resolution.
Check e.g. here - do you see "everything"?


Quote:
I don't know RPN very well, or how mt_lut should be used, but I tried:
[*wrong code*]
It shows light-gray details while still keeping white at 255.
That code is not correct. Look at the histogram. There is a gap between 235-250, that range is not used at all, because of the wrong formula.

Quote:
Since this clip is probably supposed to look like tv levels [16,235], I should ask how to properly convert TV->PC such that the video doesn't look like dynamic contrast is turned on.
That's a misconception. A clip is not supposed to "look like" TV levels.
When a clip IS TV levels, then it looks correct on TV-levels display devices, and looks washed-out on fullscale display devices. And vice versa, a PC-scale clip will look correct on fullscale devices, and overcontrasted on TVscale devices.

Ah, I start getting lengthy .... anyway, what you are trying is solely a matter of personal preference. Not any kind of "correction" that would be "needed" to do.


FWIW ... generalized LUT function with "dark point" + "factor", and "bright point" + "factor".

Code:
point0  = 8
factor0 = 2.0
point1  = 247
factor1 = 2.0

P0=string(point0)
P1=string(point1)
F0=string(factor0)
F1=string(factor1)

mt_lut("x "+P0+" < x "+F0+" * x "+P1+" > 255 255 x - "+F1+" * - x "+P0+" - "+P1+" "+P0+" - 255 "+P1+" - "+F1+" * - "+P1+" "+P0+" - / * "+P0+" 2 * + ? ?")

There really should be a levels-filter that works with control points and splines, like those brightness/levels/whatever controls that we all know from most existing image graphic editors. More than a decade of Avisynth, and nobody did that yet ...
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)

Last edited by Didée; 28th June 2010 at 08:46.
Didée is offline   Reply With Quote
Old 28th June 2010, 09:42   #36  |  Link
Bi11
Architect
 
Bi11's Avatar
 
Join Date: May 2010
Posts: 57
Quote:
Originally Posted by Didée View Post
The suspicion that you are using a badly-calibrated (or badly-featured) LCD flatscreen, and that you're trying to work around bad brightlevel resolution.
Check e.g. here - do you see "everything"?
My monitor may not be the best but I can clearly see 251 and 252, it takes a second but I can see 253 as well, and if I stare long enough I think I can see the very light gray squares at 254.
Quote:
Originally Posted by Didée View Post
That code is not correct.
I knew the expr was wrong (I didn't know the correct one), but I still posted it so you would know what I was looking for (i.e. keeping white at 255).
Quote:
Originally Posted by Didée View Post
A clip is not supposed to "look like" TV levels.
When a clip IS TV levels, then it looks correct on TV-levels display devices, and looks washed-out on fullscale display devices. And vice versa, a PC-scale clip will look correct on fullscale devices, and overcontrasted on TVscale devices.
I know what you mean, but that's not the case here. The video I have was most likely converted to pc levels when they encoded it for distribution. Their master copy is most likely tv levels. (Or maybe it was pc levels to start with and they still did a tv->pc conversion, i don't know. All I know is, when I call SmoothLevels(preset="pc2tv") I can see all the very light gray details as they were meant to be. If I then increase the levels from 235 to, say, 240 (as seen in a histogram) then some of those very light details become invisible.)

I'll experiment with the generalized LUT function to see if I can get the results I want.
Bi11 is offline   Reply With Quote
Old 28th June 2010, 10:40   #37  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,394
I won't argue against that you see what you see. But it doesn't make sense to me. Given that the display doesn't clamp at close-to-white and close-to-black, you should be able to see all details in those areas without any adjustment. After all, these levels-manipulations don't invent any new information to start with. They only shift-around the already-present data.

It could be your playback filterchain. If you see all blacks and whites in the lagom tests, but don't see all blacks and whites during playback of a PC-scale video, then some part of your playback filterchain might do clamping to TV-levels.
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 28th June 2010, 11:04   #38  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,384
Quote:
Originally Posted by Didée View Post
Code:
mt_lut("x "+P0+" < x "+F0+" * x "+P1+" > 255 255 x - "+F1+" * - x "+P0+" - "+P1+" "+P0+" - 255 "+P1+" - "+F1+" * - "+P1+" "+P0+" - / * "+P0+" 2 * + ? ?")
You're close...

That 2 on the end should clearly be F0, but the bit in the middle is wrong too.
For the third case you have (x-p0)*[(p1-p0)-(255-p1)*f1]/(p1-p0) + p0*2
when it should be (x-p0)*[255-(255-p1)*f1-p0*f0]/(p1-p0) + p0*f0

It's easier to see if you write it like this:
Code:
Y0 = P0+" "+F0+" *"
Y1 = "255 255 "+P1+" - "+F1+" * -"
mt_lut("x "+P0+" < x "+F0+" * x "+P1+" > 255 255 x - "+F1+" * - x "+P0+" - "+Y1+" "+Y0+" - "+P1+" "+P0+" - / * "+Y0+" + ? ?")
Quote:
There really should be a levels-filter that works with control points and splines, like those brightness/levels/whatever controls that we all know from most existing image graphic editors. More than a decade of Avisynth, and nobody did that yet ...
AdjustY("Spline(y, ...)")
Gavino is offline   Reply With Quote
Old 28th June 2010, 11:31   #39  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,394
Oh my, yes.

Seems it's not good to write LUTs with a bap in the left, cup'o'coffe in the right, and should've left for work five minutes ago.
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 28th June 2010, 19:43   #40  |  Link
LaTo
LaTo INV.
 
LaTo's Avatar
 
Join Date: Jun 2007
Location: France
Posts: 701
Quote:
Originally Posted by Didée View Post
There really should be a levels-filter that works with control points and splines
SmoothCurve use control points and linear interpolation...

It's on my todo list, someone has a good documentation/paper about splines?

Last edited by LaTo; 28th June 2010 at 20:21.
LaTo is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 18:30.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.