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
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 6th November 2006, 14:49   #21  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,391
Sorry for not replying ... with an all-time-bursting PM box, some PMs might slip through.

Worse is that YlevelsG/S/C indeed is wrongly implemented, and has been like that since day one.
Consequently, ffdshow "correctly" incorporates the faulty Ylevels variants ... so my complaints always were unjustified.

I am standing there with egg on my face.
__________________
- 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 20th November 2006, 09:59   #22  |  Link
Jeremy Duncan
Didée Fan
 
Jeremy Duncan's Avatar
 
Join Date: Feb 2006
Location: Canada
Posts: 1,079
Didée,

The FFdshow developer h_yamagata updated the YlevelsG/S/C using Alain2's patch.

Check it out. Rev 567
Link

FFDShow

Jeremy Duncan is offline   Reply With Quote
Old 13th December 2006, 06:06   #23  |  Link
bananacreamandpeca
Registered User
 
Join Date: Sep 2004
Posts: 160
Ok. this is interesting. I was looking for a quick way just to
control the gamma for my video.
But how do I use this? I only need the masktools.dll for avisynth,
that's all?
bananacreamandpeca is offline   Reply With Quote
Old 27th January 2007, 13:24   #24  |  Link
digitalone
Registered User
 
Join Date: Aug 2005
Posts: 29
thx for this great function Didée...but is it possible to update it using MVTools v2 semantics? thx again.
digitalone is offline   Reply With Quote
Old 27th January 2007, 13:27   #25  |  Link
Manao
Registered User
 
Join Date: Jan 2002
Location: France
Posts: 2,856
Just replace yv12lut by mt_lut
__________________
Manao is offline   Reply With Quote
Old 27th January 2007, 13:43   #26  |  Link
digitalone
Registered User
 
Join Date: Aug 2005
Posts: 29
thx a lot manao..it's working now...
digitalone is offline   Reply With Quote
Old 30th October 2007, 12:09   #27  |  Link
FlimsyFeet
Guest
 
Posts: n/a
I need some help understanding this.

I have a DVD that's too "bright" and looks a bit washed out. I can get more of a "film-ish" look if I use:

Levels(0, 0.85, 255, 0, 255)

But this pulls the brightest bits down a bit too much and gives the illusion of reduced contrast. It sounds like the adjusted curves in this script are what I need to make the dark bits darker and not touch the bright bits too much, but reading the first post it looks as if this filter was not desinged for gamma values less than 1.0? (Where it says "YlevelsG (not YlevelsS) does "inverse" scaling for gamma values < 1.0, but that's not that great. It's just for completeness.") Of course I could just try it and see what it looks like, but if someone could clarify whether I should be using this or if something else would do a better job?
  Reply With Quote
Old 30th October 2007, 12:23   #28  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 6,782
You should use a limited luminance (and chrominance) range when encoding to MPEG2 for DVD. MPEG2 encoders may expect "TV range" material (due to the fact that TV sets expect a limited signal voltage range from the receiver), and if you give them "PC range" instead, you will get overbright results especially on CRT TV sets.

You should apply the filter ColorYUV(levels="PC->TV") on full range material before encoding it.

http://avisynth.org/mediawiki/ColorYUV
LigH is offline   Reply With Quote
Old 30th October 2007, 13:36   #29  |  Link
FlimsyFeet
Guest
 
Posts: n/a
I don't think that's going to help, because the MPEG2 source should already be in TV range, I'm not doing any colourpsace conversions.
  Reply With Quote
Old 31st October 2007, 19:28   #30  |  Link
FlimsyFeet
Guest
 
Posts: n/a
My quick test:
Code:
a=ImageReader("greyscale.png").converttoyv12().histogram()
b=ImageReader("greyscale.png").converttoyv12().levels(0, 0.6, 255, 0 , 255).histogram()
c=ImageReader("greyscale.png").converttoyv12().ylevels(0, 0.6, 255, 0 , 255).histogram()
d=ImageReader("greyscale.png").converttoyv12().ylevelsg(0, 0.6, 255, 0 , 255).histogram()
e=ImageReader("greyscale.png").converttoyv12().ylevelss(0, 0.6, 255, 0 , 255).histogram()
stackvertical(a, b, c, d, e)


YLevels and YLevelsG seems to clip the black too much. YLevelsS reduces the peak white.

Using gamma values >1.0, I see similar clipping in the white.
  Reply With Quote
Old 1st November 2007, 07:02   #31  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
You might also test the coring=false option to Levels(). This option changes the range scaling from 16..235 to 0..255

Code:
...ImageReader("greyscale.png").converttoyv12().levels(0, 0.6, 255, 0 , 255, coring=false)
This should be the same as the default coring=true
Code:
...ImageReader("greyscale.png").converttoyv12().levels(16, 0.6, 235, 16 , 235, coring=false)
IanB is offline   Reply With Quote
Old 1st November 2007, 22:19   #32  |  Link
FlimsyFeet
Guest
 
Posts: n/a
I should have used the 16-235 levels in my YLevels script above!
e.g.
ImageReader("greyscale.png").converttoyv12().ylevelsg(16, 0.6, 235, 16 , 235).histogram()
is correct with no clipping.

But, is there any reason why I shouldn't do this:
Code:
ImageReader("greyscale.png").ConvertToYV12().FlimsYLevels(15).Histogram()

function FlimsYlevels(clip clp, float amp)
       { wicked="x x 16 - 34,85493 / sin "+string(amp)+" * -"
         return( clp.mt_lut(Yexpr = wicked) )  
         }

Last edited by FlimsyFeet; 10th March 2008 at 14:25.
  Reply With Quote
Old 18th February 2008, 11:30   #33  |  Link
zee944
Registered User
 
Join Date: Apr 2007
Posts: 240
Didée, this filter is a great idea. I hope you'll continue refining it. Very useful.

My problem with it that I can't call forth the effect I want. I'd like to define which range I want to boost up a little. I've played around a lot with the values, but I just can't do it.

What I want is to only affect pixels that have luma value between (say) 50 and 200. I don't want to touch pixels under and above a certain brightness. So probably the gamma curve should be shrinked to fit between 50 and 200. Is it possible?
zee944 is offline   Reply With Quote
Old 28th February 2008, 14:17   #34  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,391
Answered zee944's question here.

Summary: Possible, but not feasable to do that with MaskTools' lookup tables.
__________________
- 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 29th February 2008, 13:13   #35  |  Link
Kumo
Registered User
 
Join Date: Apr 2006
Posts: 57
i'm trying to use this filter on a jap dvd r2 anime.i'm calling ylevels in my script like : "ylevelsS(16, 1.0, 235, 0 , 255).
i can adjust input_low and output_low settings to reach a 0-255 full range (checking it with histogram)only with gamma=1.
if i try with i.e. gamma =1.6(or any other value), i get dark levels too bright with i.e. input_low=34 and too dark with next value(i.e. input_low=35, there are no mid-ways).where am i wrong?
Kumo is offline   Reply With Quote
Old 6th March 2008, 14:17   #36  |  Link
Vesi
Guest
 
Posts: n/a
I tried to test ylevels, but the problem I got is, when I try to work on source with AvsP everythink looks ok,but when rip finish I don't see any effect of ylevels in my rip...any Idea why.
I am using this script and Virtualdub for rip.

Script:
Quote:
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\DGDecode.dll")
MPEG2Source("C:\Documents and Settings\Vesi\My Documents\Test\Test.d2v")
Deblock_QED()
tfm(order=1).tdecimate()
Crop(0, 44, -0, -48)

Spline36Resize(624,304) # Spline36 (Neutral)
YlevelsS(0,1.6,255,0,255)
FFT3DFILTER(sigma=1.0,bw=32,bh=32,ow=16,oh=16,bt=3)
dull = last
sharp = dull.LimitedSharpenfaster( ss_x=1.25, ss_y=1.25,smode=4, strength=150, overshoot=1 )
Soothe( sharp, dull, 40 )
Tweak(hue=0.0, sat=1.2)
Before

With AvsP

Output
  Reply With Quote
Old 22nd April 2010, 15:47   #37  |  Link
WorBry
Registered User
 
Join Date: Jan 2004
Location: Here, there and everywhere
Posts: 1,197
FlimsyFeet,

I know this is quite an old thread, but I'm experimenting with routines for simulating 'film-looks', ideally keeping the process in YV12.
Since there seems to be no easy way to import Photoshop/Gimp curves without color space conversion (and I'm not sure if the Levels > Curves control in FFDSHow avoids that), I've been using a Masktools (mt_lutxy) function (128-centred multiply) that achieves the same result as the Overlay blend mode, found in After Effects etc.

http://forum.doom9.org/showthread.ph...67#post1387067

This effectively creates an S-shaped luma curve, the 'strength' of which can be somewhat adjusted by opacity.

I also came across your FlimsYLevels function, which produces a sinusoidal S-curve.

Quote:
Originally Posted by FlimsyFeet View Post

function FlimsYlevels(clip clp, float amp)
{ wicked="x x 16 - 34,85493 / sin "+string(amp)+" * -"
return( clp.mt_lut(Yexpr = wicked) )
}[/CODE]
I'm interested to know how you derived the calc for the the 'wicked' mt_lut expression; I want to stay in full 0 - 255 range, not 16 -235.

Cheers.
__________________
Nostalgia's not what it used to be

Last edited by WorBry; 22nd April 2010 at 15:55.
WorBry is offline   Reply With Quote
Old 23rd June 2011, 04:38   #38  |  Link
Mounir
Registered User
 
Join Date: Nov 2006
Posts: 773
I'm beginning to experiment and appreciate the benefits of this filter; sadly enough, like most of the filters it is YV12 only so i have to make an official request for YUY2 support , if that's not asking the moon.
Mounir is offline   Reply With Quote
Old 23rd June 2011, 10:56   #39  |  Link
LaTo
LaTo INV.
 
LaTo's Avatar
 
Join Date: Jun 2007
Location: France
Posts: 701
Quote:
Originally Posted by Mounir View Post
I'm beginning to experiment and appreciate the benefits of this filter; sadly enough, like most of the filters it is YV12 only so i have to make an official request for YUY2 support , if that's not asking the moon.
You can do the same with SmoothAdjust which support YV16 (and so YUY2) in avisynth 2.6.x


Or you can add YUY2 indirectly in these functions:
Code:
clip = last
ConvertToYV12()

xxxlevels(...)

ConvertToYUY2()
MergeChroma(clip)

Last edited by LaTo; 23rd June 2011 at 12:16.
LaTo is offline   Reply With Quote
Old 27th October 2019, 14:49   #40  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,829
Would anyone with a wiki account care to fix the version of Ylevels on the wiki?

For the version on the wiki, the "show_function" argument is integer, when it should be bool.
Code:
function Ylevels(clip clp,
\                int "input_low", float "gamma", int "input_high",
\                int "output_low", int "output_high", int "show_function")
And the return line has been changed to display the subtitle over the source video when show_function=true. I'm not sure if that was deliberate, but I'm also not sure why it would've been changed.

Wiki version:
Code:
return( show_function ? clp.subtitle(wicked) : clp.mt_lut(Yexpr = wicked, U=2,V=2) )
The version I've been using:
Code:
########
# Levels transforms by Didée
# Requires MaskTools v2.0 or greater
# last revision 2004-12-07; update to MaskTools v2.0 semantics 2008-03-09
#
# PARAMETERS:
#   "input_low"     : (Default: 0)
#   "gamma"         : (Default: 1.0)
#   "input_high"    : (Default: 255)
#   "output_low"    : (Default: 0)
#   "output_high"   : (Default: 255)
#   "show_function" : (Default: false) - the function to be made into a lookup-table
#                                        transform, shown in postfix notation
#
# USAGE:
#   YLevels(0, 1.2, 255, 0, 255, false)
#   YLevels(0, 1.2, 255)
#   YLevels(gamma=1.2)

# Constant
function Ylevels(clip clp,
\                int "input_low", float "gamma", int "input_high",
\                int "output_low", int "output_high", bool "show_function")
{ 
    input_low = Default(input_low, 0)
    gamma = Default(gamma, 1.0)
    input_high = Default(input_high, 255)
    output_low = Default(output_low, 0)
    output_high = Default(output_high, 255)
    show_function = Default(show_function, false)
    
    wicked = "x " +string(input_low)+ " - " +string(input_high)+ " " +string(input_low)+ " - / 1 " +string(gamma)+
    \        " / ^ " +string(output_high)+ " " +string(output_low)+ " - * " +string(output_low)+ " +"
        
    return show_function ? \
    clp.mt_lut(Yexpr = wicked, U=2,V=2).subtitle(wicked) : \
    clp.mt_lut(Yexpr = wicked, U=2,V=2)
}
         
# Gradient
function YlevelsG(clip clp,
\                int "input_low", float "gamma", int "input_high",
\                int "output_low", int "output_high", bool "show_function")
{ 
    input_low = Default(input_low, 0)
    gamma = Default(gamma, 1.0)
    input_high = Default(input_high, 255)
    output_low = Default(output_low, 0)
    output_high = Default(output_high, 255)
    show_function = Default(show_function, false)	
    
    wicked = gamma > 1.0
    \      ? "x " +string(input_low)+ " - " +string(input_high)+ " " +string(input_low)+ " - / 1 " +string(gamma)+
    \        " / ^ " +string(output_high)+ " " +string(output_low)+ " - * " +string(output_low)+ " + x * x 255 x - * + 255 /"
    \      : "x " +string(input_low)+ " - " +string(input_high)+ " " +string(input_low)+ " - / 1 " +string(gamma)+
    \        " / ^ " +string(output_high)+ " " +string(output_low)+ " - * " +string(output_low)+ " + 255 x - * x x * + 255 /"
    
    return show_function ? \
    clp.mt_lut(Yexpr = wicked, U=2,V=2).subtitle(wicked) : \
    clp.mt_lut(Yexpr = wicked, U=2,V=2)
}

# Sine
function YlevelsS(clip clp,
\                int "input_low", float "gamma", int "input_high",
\                int "output_low", int "output_high", bool "show_function")
{ 
    input_low = Default(input_low, 0)
    gamma = Default(gamma, 1.0)
    input_high = Default(input_high, 255)
    output_low = Default(output_low, 0)
    output_high = Default(output_high, 255)
    show_function = Default(show_function, false)
    
    wicked="x " +string(input_low)+ " - " +string(input_high)+ " " +string(input_low)+ " - / 1 " +string(gamma)+
    \      " / ^ " +string(output_high)+ " " +string(output_low)+ " - * " +string(output_low)+ " + x 162,97466 /" +
    \      " sin 255 * * x 255 x 162,97466 / sin 255 * - * + 255 /"
    
    return show_function ? \
    clp.mt_lut(Yexpr = wicked, U=2,V=2).subtitle(wicked) : \
    clp.mt_lut(Yexpr = wicked, U=2,V=2)
}

# Cosine
function YlevelsC(clip clp,
\                int "input_low", float "gamma", int "input_high",
\                int "output_low", int "output_high", bool "show_function")
{ 
    input_low = Default(input_low, 0)
    gamma = Default(gamma, 1.0)
    input_high = Default(input_high, 255)
    output_low = Default(output_low, 0)
    output_high = Default(output_high, 255)
    show_function = Default(show_function, false)
    
    wicked="x " +string(input_low)+ " - "+ string(input_high)+ " " +string(input_low)+ " - / 1 "+string(gamma)+
    \      " / ^ " +string(output_high)+ " " +string(output_low)+ " - * " +string(output_low)+ " + 255 x 162,97466" +
    \      " / cos 255 * - * x x 162,97466 / cos 255 * * + 255 /"
    
    return show_function ? \
    clp.mt_lut(Yexpr = wicked, U=2,V=2).subtitle(wicked) : \
    clp.mt_lut(Yexpr = wicked, U=2,V=2)
}
hello_hello is offline   Reply With Quote
Reply


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 05:14.


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