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 4th July 2010, 17:32   #41  |  Link
LaTo
LaTo INV.
 
LaTo's Avatar
 
Join Date: Jun 2007
Location: France
Posts: 701
Update 2010.07.04

v1.24:
added new interpolation mode for SmoothCurve (see interp)
LaTo is offline   Reply With Quote
Old 4th July 2010, 17:33   #42  |  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, 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 ...
done
LaTo is offline   Reply With Quote
Old 4th July 2010, 21:08   #43  |  Link
markanini
Registered User
 
Join Date: Apr 2006
Posts: 293
I tried to use smoothlevels on a heavily overexposed jpeg still image. It required a major gamma adjustment downward to 0.06 which resulted in heavy blockiness in bright areas due to 8-bit source. Tweaking smoothing and dither settings didnt yield acceptable results and trying gradfun2dbmod afterwords didnt help either. I ended up working on it in Photoshop. Prior to final gamma adjustment I converted to 16-bit, seperated the image at 0-249 & 250-256, applied biltaeral filter + noise for the high range that contained blocking and added the ranges back together which yielded an acceptable result after gamma adjustment.

During the process I spent some time trying different bluring filters, box, median, gauss and I settled for bilateral as the shapes of the blocks turned out the most natural looking while retaining definition but the gradiations werent particularly smooth which is why I added noise.

May be some of these ideas could be implemented into your plugins like a bilateral mode or stronger processing in the outer extreme tonal ranges?

Last edited by markanini; 4th July 2010 at 21:33. Reason: Left some stuff out
markanini is offline   Reply With Quote
Old 5th July 2010, 07:46   #44  |  Link
royia
Drazick
 
Join Date: May 2003
Location: Israel
Posts: 137
Quote:
Originally Posted by LaTo View Post
SmoothCurve use control points and linear interpolation...

It's on my todo list, someone has a good documentation/paper about splines?
One easy way would be looking at Matlab's code for Splines.
royia is offline   Reply With Quote
Old 5th July 2010, 08:09   #45  |  Link
LaTo
LaTo INV.
 
LaTo's Avatar
 
Join Date: Jun 2007
Location: France
Posts: 701
Quote:
Originally Posted by royia View Post
One easy way would be looking at Matlab's code for Splines.
Thanks but it's already in v1.24

Quote:
Originally Posted by markanini View Post
I tried to use smoothlevels on a heavily overexposed jpeg still image. It required a major gamma adjustment downward to 0.06 which resulted in heavy blockiness in bright areas due to 8-bit source. Tweaking smoothing and dither settings didnt yield acceptable results and trying gradfun2dbmod afterwords didnt help either. I ended up working on it in Photoshop. Prior to final gamma adjustment I converted to 16-bit, seperated the image at 0-249 & 250-256, applied biltaeral filter + noise for the high range that contained blocking and added the ranges back together which yielded an acceptable result after gamma adjustment.

During the process I spent some time trying different bluring filters, box, median, gauss and I settled for bilateral as the shapes of the blocks turned out the most natural looking while retaining definition but the gradiations werent particularly smooth which is why I added noise.

May be some of these ideas could be implemented into your plugins like a bilateral mode or stronger processing in the outer extreme tonal ranges?
You can make this (blur+noise) easily with mt_masktools:
Code:
source=last
process=source.bilateral().noise()
mt_lutxy(source,process,"x 250 >= y x ?",chroma="copy")
SmoothLevels(gamma=0.06,Smode=3)
LaTo is offline   Reply With Quote
Old 5th July 2010, 14:25   #46  |  Link
LaTo
LaTo INV.
 
LaTo's Avatar
 
Join Date: Jun 2007
Location: France
Posts: 701
v1.26:
Smode=3 is now the default (instead of Smode=1)
tweaked smoothing sensitivity
updated documentation about Smode
LaTo is offline   Reply With Quote
Old 5th July 2010, 18:49   #47  |  Link
markanini
Registered User
 
Join Date: Apr 2006
Posts: 293
Thanks for the script LaTo. I may have to try it out some time
Still, When I fed Smoothadjust with a non mod4 source and smoothing strenght maxed out the erronious result that came up looked a lot like box blur to me. Maybe it's naive to assume that's what smoothadjust uses but I'm still not getting satisfactory results on the image I mentioned before with the newest version.
No chance of seeing a median Smode 5?
markanini is offline   Reply With Quote
Old 5th July 2010, 18:54   #48  |  Link
LaTo
LaTo INV.
 
LaTo's Avatar
 
Join Date: Jun 2007
Location: France
Posts: 701
Quote:
Originally Posted by markanini View Post
Thanks for the script LaTo. I may have to try it out some time
Still, When I fed Smoothadjust with a non mod4 source and smoothing strenght maxed out the erronious result that came up looked a lot like box blur to me. Maybe it's naive to assume that's what smoothadjust uses but I'm still not getting satisfactory results on the image I mentioned before with the newest version.
No chance of seeing a median Smode 5?
And with Smode=4? Results should be much better for high strength.
LaTo is offline   Reply With Quote
Old 9th July 2010, 09:53   #49  |  Link
markanini
Registered User
 
Join Date: Apr 2006
Posts: 293
@ LaTo:
Blocking is still there. Its an extreme case though due to lighning conditions being comparable to 'film noir' and besides being overexposed the picture seems to have had and s-curve applied. So I'd rather blame 8-bit format and jpeg compression than smoothlevels.

I've found better results than before on blocky ranges by employing anistotrophic filtering. Such a filter would be ridicoulously slow for video though.
There was also the issue of mosquito noise which was removed perfectly when filtering was limited to outliers above a set threshold, leaving original grainy texture intact.
I hope I've given you some food for thought and anyone else dealing with sources that have severe artefacts afterlarge level/gamma adjustment. Unfortunately I'm avisynth illiterate so I cant write script examples of the processing I've done in Photoshop.

Summaring my method:
Upping bit depth(optional).
Bluring/denoising +adding noise to level ranges that contain blocking.
Levels/gamma adjustment.
Blurring/denoising outliers to remove mosquito noise.
Denoise and sharpen to taste.

Results should be kickass.

Last edited by markanini; 9th July 2010 at 10:12.
markanini is offline   Reply With Quote
Old 13th July 2010, 15:32   #50  |  Link
Emulgator
Big Bit Savings Now !
 
Emulgator's Avatar
 
Join Date: Feb 2007
Location: close to the wall
Posts: 629
Many thanks for 1.26, LaTo !
Cubic splines and their smoother derivatives work beautifully on Y and finally U and V !
Smooth histograms from poor sources at last, Smode=4 and strength=100 are welcome !
__________________
Die toten Augen von Friedrichshain: "Data reduction ? Yep, Sir. We're working on that issue. Synce invntoin uf lingöage..."
"To bypass shortcuts and find suffering"...no, it was somehow different...
Emulgator is offline   Reply With Quote
Old 13th July 2010, 17:53   #51  |  Link
dansrfe
Registered User
 
Join Date: Jan 2009
Posts: 1,212
LaTo,

I have a couple of questions which I hope won't be flagged as completely noob questions.

1) What are the apparent and technical differences between brightness and gamma.
2) What exactly is contrast technically speaking and as changing it would show in video.

I know what most of these "apparently" do but i only know how to use them after a long time of trial-and-error. I would like to know the exact differences between the three in such a way that it would take me less time to decide the what final values I should use and also what will end up looking good. Just some easy to understand yet very exclusive and specific uses and definitions of each.

Also where can I find the correct parameter usages for mt_masktools functions. Something for a relatively new person in using mt_masktools functions directly rather than indirectly through other functions and scripts. I just want to start getting the feel of using mt_masktools functions separately.

Thanks.

Last edited by dansrfe; 13th July 2010 at 17:55.
dansrfe is offline   Reply With Quote
Old 13th July 2010, 18:36   #52  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,374
Quote:
Originally Posted by dansrfe View Post
1) What are the apparent and technical differences between brightness and gamma.
2) What exactly is contrast technically speaking and as changing it would show in video.
http://www.poynton.com/notes/brightness_and_contrast/
http://www.poynton.com/GammaFAQ.html
http://www.n9pby.com/psp/psp3%20-%20...0contrast.html
Quote:
Also where can I find the correct parameter usages for mt_masktools functions.
Have you looked at the mt_masktools documentation?
Gavino is offline   Reply With Quote
Old 13th July 2010, 18:44   #53  |  Link
Emulgator
Big Bit Savings Now !
 
Emulgator's Avatar
 
Join Date: Feb 2007
Location: close to the wall
Posts: 629
Although I am not the questioned one:

Applying Brightness just adds the value of <brightness> to every Y value of every pixel.
In YUV U,V stay untouched, in RGB the visual differences between colours stay untouched.

Applying Brightness+10 would make a normally perfectly exposed picture look pale and clip the lights.
Brightness +10: 0->10; 10->20; 63->73; 127->137; 191->201; 235->245; 245->255; 255->255

Applying Brightness-10 would make a normally perfectly exposed picture look dark and clip the shades.
Brightness -10: 0->0; 10->0; 63->53; 127->117; 191->181; 235->225; 245->235; 255->245

So Brightness just shifts Y values and can IMHO be only of use
if a shifting of the exact same characteristics shall be compensated.
But this would happen very rarely under normal circumstances.


Contrast applies a slope with ratio=<contrast> onto Y only,
the neutral point being Y=127,
in YUV U and V (in RGB the visual difference between primary colours) stay untouched.
The difference between the Y-value of the actual pixel and the neutral point Y=127 is amplified by <contrast>
Contrast=1.0 is neutral.
Contrast +2.0: 0->0; 32->0; 64->1; 127->127; 191->255; 235->255; 245->255; 255->255
Contrast +0.5: 0->62; 32->80; 64->96; 127->127; 191->159; 235->181; 245->186; 255->191
Applying Contrast is useful only if the resulting curve does not clip the histogram.
This would be the case for an underexposed and pale-shadowed source.
Applying Contrast <1 may clip the lights and swallow the shadows.
An already clipped source can not be mended by applying contrast<1.
The clipping would only be shifted.

Gamma applies a curve with the exponent <gamma> to Y only;
the neutral points being Y=0, Y=255
in YUV U and V (in RGB the visual difference between primary colours) stay untouched.
Gamma=1.0 is neutral and won't change the source. In any case the whites and blacks stay untouched.
Gamma=2.0 brightens the lights, midtones and lifts the shadows, but pure white and black stay untouched.
Gamma=0.5 dims the lights, midtones and darkens the shadows, but pure white and black stay untouched.


To me Gamma is the most valuable tuning, because it won't clip.

Clipping is irreversible and is to be avoided in any case.

It is useful to use Histogram and if appropriate, a tiny Y-shift by brightness before applying Gamma.
Because Gamma can not shift, only multiply.


http://upload.wikimedia.org/wikipedi...rast_Gamma.png

But the master of it all is applying an arbitrary cubic spline transfer function to Y
using adjustY or even better LaTo's SmoothCurve after applying the necessary shifts by LaTo's SmoothTweak.

Here you can compensate for any transfer characteristic of video cameras or film stock in any decay state..
And the best of it: LaTo's Smooth set dithers and works for U and V too !

P.S. Ah, Gavino was faster.
__________________
Die toten Augen von Friedrichshain: "Data reduction ? Yep, Sir. We're working on that issue. Synce invntoin uf lingöage..."
"To bypass shortcuts and find suffering"...no, it was somehow different...

Last edited by Emulgator; 13th July 2010 at 18:57.
Emulgator is offline   Reply With Quote
Old 13th July 2010, 19:40   #54  |  Link
dansrfe
Registered User
 
Join Date: Jan 2009
Posts: 1,212
Wow. I'm impressed. All of the explanations are so good! Thanks Emulgator and Gavino! So if I understand correctly. Brightness, contrast, and gamma are in a hierarchy of adding, multiplying, and exponential, respectively, to its own scale of the Y plane values. Brightness just shifts the Y values, contrast applies a slope on a ratio used mainly for exposure adjustments. And gamma affects the lights, midtones, and shadows on an exponential scale. Also I have yet another question. I'm not exactly sure what SmoothCurve does or more so how to use it. Does it do level adjustments with options to apply to all three of the YUV planes separately? If I am using all three of LaTo's functions which order should they be used in? SmoothTweak, SmoothCurve, SmoothLevels or would it be sufficient to use just SmoothTweak and SmoothCurve if I plan on making level adjustments as well? The diagram of all the brightness, contrast, and gamma curves is great
dansrfe is offline   Reply With Quote
Old 16th July 2010, 08:54   #55  |  Link
Emulgator
Big Bit Savings Now !
 
Emulgator's Avatar
 
Join Date: Feb 2007
Location: close to the wall
Posts: 629
You will easily find out where you land if you just add

#ConvertToYV12(interlaced=true)#Histogram needs YV12 !
histogram(mode="classic")
histogram(mode="levels")

before and after SmoothTweak/Curve/Levels.

Here is a small piece of my recent script to pre-compensate
a dead, overexposed and purple-sick film transfer.
First I had to shift the U and V planes using SmoothTweak,
leaving Y untouched
then I had to use SmoothCurve to
remap Y nicely and spread the U and V planes
to smoothly extend to saturated colours where they once belonged.
SmoothLevels were not needed in this case.

Code:
#/*#-------------------------------------------------------------LaTo's Smooth Adjust Set----------------------------------------------------------------
#ConvertToYV12(interlaced=true)#LaTo's Smooth set needs YV12 !
#Smooth means: internal results will be dithered, a smooth histogram will be achieved, banding avoided.
#It won't dither a source that came in banding !
SmoothTweak(Smode=4, strength=100, brightness=0.0, contrast=1.0, saturation=1.0, hue1=+2, hue2=-10, limiter=true)#Bright/Cont/Sat/Hue1(G->B)/Hue2(G->R)-Adjustments
SmoothCurve(Smode=4, strength=100, interp=100, limiter=true, \
Ycurve="0-15;16-16;127-120;200-180;220-195;230-202;240-210;248-218;255-230", \
Ucurve="0-16;100-40;127-127;140-180;255-240", \
Vcurve="0-16;100-80;135-127;140-135;150-160;255-240")
#SmoothCurve(Smode=4, strength=100, interp=100, limiter=true, \
#Ycurve="0-15;16-16;127-120;200-180;220-195;230-202;240-210;248-218;255-230", \
#Ucurve="0-16;100-40;127-127;140-180;255-240", \
#Vcurve="0-16;100-30;135-127;140-140;255-240")
#SmoothLevels(gamma=0.78, Lmode=2, Ecenter=128)#Gamma-Adjustments,Lmode=1: dark and bright stay unaffected,=2: dark stays unaffected, =3: bright stays unaffected
#SmoothLevels(0,1.2,255,32,235,Lmode=1,Ecenter=64,protect=16)
#*/#----------------------------------------------------------End of LaTo's Smooth Adjust Set-----------------------------------------------------------
P.S. While using splines, be aware of the intricacy of spline points.
If you specify these too close and too differing these may force steep curves
with negative slopes which you might not intend...
A print of the resulting transfer function would come in handy.
__________________
Die toten Augen von Friedrichshain: "Data reduction ? Yep, Sir. We're working on that issue. Synce invntoin uf lingöage..."
"To bypass shortcuts and find suffering"...no, it was somehow different...

Last edited by Emulgator; 16th July 2010 at 09:05.
Emulgator is offline   Reply With Quote
Old 17th July 2010, 09:00   #56  |  Link
LaTo
LaTo INV.
 
LaTo's Avatar
 
Join Date: Jun 2007
Location: France
Posts: 701
Quote:
Originally Posted by Emulgator View Post
P.S. While using splines, be aware of the intricacy of spline points.
If you specify these too close and too differing these may force steep curves
with negative slopes which you might not intend...
A print of the resulting transfer function would come in handy.
A debug view is planned, but these days I am working on another plugin...

So for the moment, you can check using GIMP->Color->Curves panel... With interp=50 in SmoothCurve, the result is very close to the one used in Gimp.
LaTo is offline   Reply With Quote
Old 5th September 2010, 08:47   #57  |  Link
LaTo
LaTo INV.
 
LaTo's Avatar
 
Join Date: Jun 2007
Location: France
Posts: 701
Update 2010.09.05

v1.30:
fixed a bug in spline interpolation
cleaned various stuff
LaTo is offline   Reply With Quote
Old 5th September 2010, 10:12   #58  |  Link
sonu patel
Registered User
 
Join Date: Jan 2009
Posts: 22
i need help i get error can any one tell me ehy i get error ......as i put avs file in fillter pluging

LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\gradfun2db.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\RemoveGrainHD.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\mt_masktools-26.dll")

this requirment plugin also

SmoothLevels(gamma=1.6,Ecenter=32,Lmode=1)

Last edited by sonu patel; 5th September 2010 at 11:16.
sonu patel is offline   Reply With Quote
Old 5th September 2010, 10:15   #59  |  Link
LaTo
LaTo INV.
 
LaTo's Avatar
 
Join Date: Jun 2007
Location: France
Posts: 701
Quote:
Originally Posted by sonu patel View Post
i need help i get error can any one tell me ehy i get error ......as i put avs file in fillter pluging

LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\gradfun2db.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\RemoveGrainHD.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\mt_masktools-26.dll")

this requirment plugin also

SmoothLevels(gamma=1.6,Ecenter=32,Lmode=1)
You need to load "SmoothAdjust-x86.dll" for 32bits or "SmoothAdjust-x64.dll" for 64bits.
LaTo is offline   Reply With Quote
Old 5th September 2010, 10:22   #60  |  Link
sonu patel
Registered User
 
Join Date: Jan 2009
Posts: 22
Quote:
Originally Posted by LaTo View Post
You need to load "SmoothAdjust-x86.dll" for 32bits or "SmoothAdjust-x64.dll" for 64bits.
can u have the "SmoothAdjust-x86.dll" for 32bits i canot find plz upload it ....plzz thnks in advance
sonu patel 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 19:08.


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