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

Closed Thread
 
Thread Tools Search this Thread Display Modes
Old 5th May 2008, 16:34   #1  |  Link
LaTo
LaTo INV.
 
LaTo's Avatar
 
Join Date: Jun 2007
Location: France
Posts: 701
SmoothLevels [depreciated version, see SmoothAdjust]

Code:
#########################################################################################
###                                                                                   ###
###                      function Smooth Levels : SmoothLevels()                      ###
###                                                                                   ###
###                                v1.02 by "LaTo INV."                               ###
###                                                                                   ###
###                                  28 January 2009                                  ###
###                                                                                   ###
#########################################################################################
### 
### 
### /!\ Needed filters : Masktools (v2.0a35), Removegrain (v1.0PR), GradFun2db (v1.0).
### --------------------
### 
###
### USAGE: SmoothLevels(input_low, gamma, input_high, output_low, output_high, 
###                     chroma, limiter,
###                     Lmode, DarkSTR, BrightSTR, Ecenter, protect, Ecurve,
###                     Smode, Mfactor, RGmode, useGF,
###                     show, screenW, screenH, preset)
###
###
###
### +---------+
### | GENERAL |
### +---------+
###
### Levels options:
### ---------------
### input_low, gamma, input_high, output_low, output_high [default: 0, 1.0, 255, 0, 255]
### 
### chroma [default: 50]
### ---------------------
### 0   = no chroma processing     (similar as Ylevels)
### xx  = intermediary
### 100 = normal chroma processing (similar as Levels)
### 
### limiter [default: 0]
### --------------------
### 0 = no limiter             (similar as Ylevels)
### 1 = input limiter
### 2 = output limiter         (similar as Levels: coring=false)
### 3 = input & output limiter (similar as Levels: coring=true)
###
###
###
### +----------+
### | LIMITING |
### +----------+
###
### Lmode [default: 0]
### ------------------
### 0 = no limit
### 1 = limit conversion on dark & bright areas (apply conversion @0%   at luma=0 & @100% at luma=Ecenter & @0% at luma=255)
### 2 = limit conversion on dark areas          (apply conversion @0%   at luma=0 & @100% at luma=255)
### 3 = limit conversion on bright areas        (apply conversion @100% at luma=0 & @0%   at luma=255)
###
### DarkSTR [default: 100]
### ----------------------
### Strength for limiting: the higher, the more conversion are reduced on dark areas (for Lmode=1&2)
###
### BrightSTR [default: 100]
### ------------------------
### Strength for limiting: the higher, the more conversion are reduced on bright areas (for Lmode=1&3)
###
### Ecenter [default: 128]
### ----------------------
### Center of expression for Lmode=1
### 
### protect [default: -1]
### ---------------------
### -1  = protect off
### >=0 = pure black protection
###       ---> don't apply conversion on pixels egal or below this value 
###            (ex: with 16, the black areas like borders 
###                 and generic are untouched so they don't look washed out)
###
### Ecurve [default: 0]
### -------------------
### Curve used for limit & protect:
### 0 = use sine curve
### 1 = use linear curve
###
###
###
### +-----------+
### | SMOOTHING |
### +-----------+
###
### Smode [default: -2]
### -------------------
### 2  = smooth on, maxdiff must be < to "255/Mfactor"
### 1  = smooth on, maxdiff must be < to "128/Mfactor"
### 0  = smooth off
### -1 = smooth on if maxdiff < "128/Mfactor", else off
### -2 = smooth on if maxdiff < "255/Mfactor", else off
###
### Mfactor [default: 2]
### --------------------
### The higher, the more precise but the less maxdiff alowed: 
### maxdiff=128/Mfactor for Smode1&-1 and maxdiff=255/Mfactor for Smode2&-2
###
### RGmode [default: 12]
### --------------------
### In strength order: + 19 > 12 >> 20 > 11 -
###
### useGF [default: true]
### ---------------------
### Use gradfun2db on top of removegrain: prevent posterize when doing levels conversion
### 
###
###
### +--------+
### | OTHERS |
### +--------+
###
### show [default: false]
### ---------------------
### Show the debug clip
###
### screenW [default: 1280]
### -----------------------
### Screen horizontal resolution for debug clip
###
### screenH [default: 1024]
### ----------------------
### Screen vertical resolution for debug clip
###
### preset: 
### -------
### pc2tv = "PC -> TV" conversion
### tv2pc = "TV -> PC" conversion 
### 
### 
#########################################################################################

Old scripted version : SmoothLevels v1.02

-->See SmoothAdjust for up-to-date version!



Comparaison SmoothLevels <-> Levels:

Source

SmoothLevels(preset="tv2pc",chroma=2)

Levels(16,1.0,235,0,255,coring=false)


_

Last edited by LaTo; 5th June 2010 at 14:51.
LaTo is offline  
Old 6th May 2008, 18:48   #2  |  Link
rfmmars
Registered User
 
Join Date: Feb 2004
Posts: 743
Two problems

I am running into two problems, first if color is set to 1 or 2 any ajustments to levels will create a bright green or redish-pink screen.

Second is I can't get "mode" to work, error on "y","s" or"g"



Code:
Ulevels(chroma=0,mode=y,protect=true,input_low=[<"Low brt (0)", 0, 150, 31>],Gamma=[<"Gamma (1)", .2, 3.00, 1.11>],Input_high=[<"Brt High (255)", 0, 255, 210>],output_low=[<"Output Low Val (0)", 0, 100, 29>],output_high=[<"Output Hi Val(255)", 0, 255, 218>])#,1.0,123,0,200)
Richard
photorecall.net
rfmmars is offline  
Old 6th May 2008, 18:54   #3  |  Link
LaTo
LaTo INV.
 
LaTo's Avatar
 
Join Date: Jun 2007
Location: France
Posts: 701
For mode:
Code:
Ulevels(mode="Y")
and not:
Code:
Ulevels(mode=Y)
For the chroma error, maybe an old version of Masktools or Removegrain. (no problem on my pc)

RemoveGrain1.0 prerelease: http://home.arcor.de/kassandro/Remov...emoveGrain.rar

MT MaskTools 2.0a32: http://manao4.free.fr/masktools-v2.0a32.zip


Last edited by LaTo; 6th May 2008 at 19:09.
LaTo is offline  
Old 6th May 2008, 19:00   #4  |  Link
Blue_MiSfit
Derek Prestegard IRL
 
Blue_MiSfit's Avatar
 
Join Date: Nov 2003
Location: Los Angeles
Posts: 5,988
Looks nice! Thanks for your efforts!
__________________
These are all my personal statements, not those of my employer :)
Blue_MiSfit is offline  
Old 6th May 2008, 19:01   #5  |  Link
rfmmars
Registered User
 
Join Date: Feb 2004
Posts: 743
Quote:
Originally Posted by LaTo View Post
For mode:
Code:
Ulevels(mode="Y")
and not:
Code:
Ulevels(mode=Y)
For the chroma error, maybe an old version of Masktools or Removegrain. (no problem on my pc)

RemoveGrain1.0 prelease: http://home.arcor.de/kassandro/Remov...emoveGrain.rar

MT MaskTools 2.0a35: http://manao4.free.fr/masktools-v2.0a32.zip

Ok I will try those versions you posted, many thanks!

EDIT: Yes that did it, NO only the Mode works.


Richard

Last edited by rfmmars; 6th May 2008 at 21:42.
rfmmars is offline  
Old 6th May 2008, 21:44   #6  |  Link
rfmmars
Registered User
 
Join Date: Feb 2004
Posts: 743
The mode works but the color problems remains, first I though it was fixed but I had the color mode set to "0"

I will try it on another computer.

Richard
rfmmars is offline  
Old 8th May 2008, 17:06   #7  |  Link
LaTo
LaTo INV.
 
LaTo's Avatar
 
Join Date: Jun 2007
Location: France
Posts: 701
any others feedback???
LaTo is offline  
Old 8th May 2008, 18:39   #8  |  Link
rfmmars
Registered User
 
Join Date: Feb 2004
Posts: 743
I have installed it on another computer, a AMD 3.2 gig and if I select "Color mode" 1 or 2, any adjustment to the input or output sliders, it causes a color shift. It can be balanced out but I don't think that's how it should work. Gamma causes no change in color.

Next I am going to install it to a Intel MT machine to see what happens.

You might want to post in detail more on how and what its does.

Thanks,

Richard
rfmmars is offline  
Old 8th May 2008, 22:20   #9  |  Link
45tripp
Dolphin Blue
 
45tripp's Avatar
 
Join Date: Mar 2007
Posts: 336
i get the same as richard
__________________
injected with feelings; with no final fading
45tripp is offline  
Old 9th May 2008, 01:33   #10  |  Link
lexor
Registered User
 
Join Date: Jan 2004
Posts: 849
I am on AMD single core and I got the 2 filters linked by LaTo in his second post. While I don't see any color 1/2 settings, but since Richard bolded chroma, I'm assuming he's talking about chroma=1/2, both of those work flawlessly for me. And I like the colour correction quality much better than FFDshow's built in Levels, new King!

Also Richard maybe you should try with a simpler line? I use ulevels(chroma=2, preset="tv2pc") does that work for you or are you getting artifacts?
__________________
Geforce GTX 260
Windows 7, 64bit, Core i7
MPC-HC, Foobar2000

Last edited by lexor; 9th May 2008 at 01:39.
lexor is offline  
Old 9th May 2008, 07:42   #11  |  Link
rfmmars
Registered User
 
Join Date: Feb 2004
Posts: 743
Quote:
Originally Posted by lexor View Post
I am on AMD single core and I got the 2 filters linked by LaTo in his second post. While I don't see any color 1/2 settings, but since Richard bolded chroma, I'm assuming he's talking about chroma=1/2, both of those work flawlessly for me. And I like the colour correction quality much better than FFDshow's built in Levels, new King!

Also Richard maybe you should try with a simpler line? I use ulevels(chroma=2, preset="tv2pc") does that work for you or are you getting artifacts?
Yes the presets work but that is of no use for me. I deal with faded, color shifted old 8mm and 16mm films so I need to adjust the levels without changing the chroma.



So something needs to be fixed or its of little use to me.

Richard
rfmmars is offline  
Old 9th May 2008, 13:36   #12  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,389
The color shifting is no mystery. Regarding chroma, the function scales chroma values linearily from [in(put)_low,in(put)_high] to [out(put)_low,out(put)_high]. To keep colors neutral, both the input/output pairs have to be symmetric to 128.
The point is that these (chroma) values are directly derived from the luma-targetting parameters. Hence, if the in/out/low/high values for luma happen to be symmetric to 128, then you get correct colors. If they aren't, then you get a color shift.

Since you probably don't ever want any kind of color shifting from a *levels* function (if you need that, you'd use something else), a suggestion:
Use (output_high - output_low) / (input_high - input_low) as scaling factor cF, then use "x 128 - cF * 128 +" for the chroma channels. Gives the same effect if luma in/out.. points are symmetric, and a reasonable effect if they aren't.

Introducing completely independent chroma parameters is another option.
__________________
- 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  
Old 9th May 2008, 15:08   #13  |  Link
fibbingbear
Ursus arctos horribilis
 
fibbingbear's Avatar
 
Join Date: Dec 2007
Posts: 186
Quote:
Originally Posted by LaTo View Post

II. First example (levels) :


Original 16-235
...

ColorYUV(mode="pc->tv").ColorYUV(mode="tv->pc")
...

ULevels(preset="pc2tv").ULevels(preset="tv2pc")
...
Maybe I'm not understanding something, but if the original is 16-235, wouldn't you want to go tv->pc and then pc->tv? You have pc->tv->pc.

I know that you meant it as an example that ULevels does a better job of preserving the original if you do the inverse, but it wouldn't the example work better if it was based on a real transformation you might do?

I admit, I don't understand a lot about levels stuff, so correct me if I'm wrong.

Also, why is half-croma preferred? I'd think that you'd want full chroma... explain why this isn't the case
fibbingbear is offline  
Old 9th May 2008, 20:20   #14  |  Link
LaTo
LaTo INV.
 
LaTo's Avatar
 
Join Date: Jun 2007
Location: France
Posts: 701
Quote:
Originally Posted by Didée View Post
The color shifting is no mystery. Regarding chroma, the function scales chroma values linearily from [in(put)_low,in(put)_high] to [out(put)_low,out(put)_high]. To keep colors neutral, both the input/output pairs have to be symmetric to 128.
The point is that these (chroma) values are directly derived from the luma-targetting parameters. Hence, if the in/out/low/high values for luma happen to be symmetric to 128, then you get correct colors. If they aren't, then you get a color shift.

Since you probably don't ever want any kind of color shifting from a *levels* function (if you need that, you'd use something else), a suggestion:
Use (output_high - output_low) / (input_high - input_low) as scaling factor cF, then use "x 128 - cF * 128 +" for the chroma channels. Gives the same effect if luma in/out.. points are symmetric, and a reasonable effect if they aren't.

Introducing completely independent chroma parameters is another option.
Yes, I saw the issue yesterday but I haven't time to update... But thanks for the report, I will post a fix when I can... (use chroma=0 for the moment)
LaTo is offline  
Old 10th May 2008, 12:47   #15  |  Link
LaTo
LaTo INV.
 
LaTo's Avatar
 
Join Date: Jun 2007
Location: France
Posts: 701
The chroma expression was on my todo list, but I forgot to change it because I made my tests with symmetric input/output... I'm tired

So, the new version 8.05d fix the chroma shift!

Last edited by LaTo; 10th May 2008 at 15:35.
LaTo is offline  
Old 10th May 2008, 13:04   #16  |  Link
LaTo
LaTo INV.
 
LaTo's Avatar
 
Join Date: Jun 2007
Location: France
Posts: 701
Quote:
Originally Posted by fibbingbear View Post
Also, why is half-croma preferred? I'd think that you'd want full chroma... explain why this isn't the case
"Avisynth Levels" process the chroma with the "same factor" as the chroma, so it will change a lot the color saturation.
--> it's chroma=2

"Didée Ylevels" doesn't process the chroma at all.
--> it's chroma=0

I think that a balance of the two method is a good compromise: change the chroma less (division by 2) than the luma to preserve a bit the color saturation.
--> it's chroma=1
LaTo is offline  
Old 10th May 2008, 22:37   #17  |  Link
rfmmars
Registered User
 
Join Date: Feb 2004
Posts: 743
This is much better, thanks!

Richard
rfmmars is offline  
Old 15th May 2008, 09:45   #18  |  Link
cyberbeing
Broadband Junkie
 
Join Date: Oct 2005
Posts: 1,859
chroma=2 is broken with the new version. chroma=1 works fine.


Also, could you please explain the difference between the three modes?
cyberbeing is offline  
Old 15th May 2008, 12:51   #19  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,389
May I offer a fix ...


Delete: ( it's a) probably wrong, and b) superfluous due to the following fix)
Code:
in_low   = (chroma == 2) ? round(input_low/2) : round(input_low/4)
in_high  = (chroma == 2) ? round(input_high/2) : round((input_high+(255-input_high)/2)/2)
out_low  = (chroma == 2) ? round(output_low/2) : round(input_low/4)
out_high = (chroma == 2) ? round(output_high/2) : round((output_high+(255-output_high)/2)/2)

Replace:
Code:
### CHROMA
exprC = "x 128 - 0 < 0 x 128 - abs "+string(in_low)+" - "+string( .... # etc., veeery long line ...
exprC = ( chroma == 0 ) ? "x" : exprC
with
Code:
### CHROMA
scaleC = (float(output_high)-output_low)/(input_high-input_low)
scaleC = chroma==2 ? scaleC : (scaleC+1.0)/2
exprC  = "x 128 - "+string(scaleC)+" * 128 +"
exprC  = ( chroma == 0 ) ? "x" : exprC
That's what I had suggested somewhere above, and surprise, it works as supposed.
__________________
- 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  
Old 15th May 2008, 16:18   #20  |  Link
lexor
Registered User
 
Join Date: Jan 2004
Posts: 849
mode="S" seems broken, Y and G identical picture (or close enough to be identical), and S is much worse. You know how if you don't use any levels the whole picture looks like it has this grayish overlay, if mode S is active that overlay isn't removed, it just gets slightly reduced. Also protect=true only seems to work with mode S, and is broken for Y and G (by broken I mean solid black parts of the picture are replaced with weird gray)

This like works fine: Ulevels(mode="Y", chroma=1, smooth=0, preset="tv2pc")
This one looks too gray: Ulevels(mode="S", chroma=1, smooth=0, preset="tv2pc")
This one has black replaced: Ulevels(mode="Y", chroma=1, smooth=0, protect=true, preset="tv2pc")
__________________
Geforce GTX 260
Windows 7, 64bit, Core i7
MPC-HC, Foobar2000

Last edited by lexor; 15th May 2008 at 16:23.
lexor is offline  
Closed Thread

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 07:28.


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