Log in

View Full Version : SmoothAdjust [v3.20 - Update 2015/11/15]


Pages : [1] 2 3 4 5 6 7 8 9 10

LaTo
5th June 2010, 14:42
+-------------------------------------------------------------------------------------------------------+
| |
| SmoothAdjust plugin: SmoothLevels(), SmoothTweak(), SmoothCurve(), SmoothCustom() & SmoothTools() |
| |
| v3.20 by "LaTo INV." |
| |
| 15 November 2015 |
| |
+-------------------------------------------------------------------------------------------------------+



I. DESCRIPTION
II. DISCLAIMER
III. INSTALLATION
IV. REQUIREMENTS
V. MULTITHREADING
VI. USAGE
VII. COMMON SETTINGS
VIII. SMOOTHLEVELS - GENERAL SETTINGS
IX. SMOOTHLEVELS - LIMITING SETTINGS
X. SMOOTHTWEAK - GENERAL SETTINGS
XI. SMOOTHTWEAK - LIMITING SETTINGS
XII. SMOOTHCURVE SETTINGS
XIII. SMOOTHCUSTOM SETTINGS
XIV. SMOOTHTOOLS SETTINGS
XV. 16 BITS SETTINGS
XVI. CHANGELOG



I. DESCRIPTION :
================

SmoothAdjust is a set of 5 plugins to make YUV adjustements:
- SmoothLevels allows to change levels & gamma with optional limiting
- SmoothTweak allows to change brightness, contrast, saturation & hue
- SmoothCurve allows to change a plane according to a fixed curve
- SmoothCustom allows to change a plane according to a custom expression
- SmoothTools allows to use all the previous filters in one single pass

These 5 plugins have a smoothing & dithering algorithm to avoid banding issue.
Calculations are made in 32bits float to avoid rounding errors and artifacts.
SmoothAdjust is multithreaded (up to 16 threads) and SSE2/AVX2 optimized.

For automatic adjustments, see the "AutoAdjust" standalone plugin.



II. DISCLAIMER :
================

This program is free for non-commercial use only and must be distributed
in its original form without any modification, including this documentation file.
This program is provided as-is in the hope it will be useful but
without any warranty, including any hypothetical damages or issues.

The official home page is "http://forum.doom9.org/showthread.php?t=154971",
it always contains the latest version of this program.
This page acts as the official support center, also the author is reachable
through his member page: "http://forum.doom9.org/member.php?u=131032".

This plugin has required a lot of work and hundreds of coding hours, so if you like
it and feel the need to reward or inspire the author then please consider donating.
Donations are a fast, easy and secure operation through Paypal: simply follow the
link into the "Donate.url" shortcut (you do not need a Paypal account to donate).
All donations will be very useful and I thank in advance all the generous people,
also if you are on the doom9's forum please specify your nickname when donating.



III. INSTALLATION :
===================

There are different versions of SmoothAdjust to suit all installations of Avisynth:
- x86 builds are for Avisynth 32bits
- x64 builds are for Avisynth 64bits



IV. REQUIREMENTS :
==================

- Avisynth v2.6.x or Avisynth Plus
- YUV Planar (Y8, YV411, YV12, YV16, YV24)
- 8bits or 16bits (MSB/LSB)



V. MULTITHREADING :
===================
SmoothAdjust is internally multithreaded with official Avisynth version.
If AvisynthPlus or AvisynthMT is detected, internal multithreading is automatically disabled
even if external multithreading isn't used (this can be reactivated in parameters).

SmoothAdjust is designed to work with external multithreading, so fastest MT mode can be used.
With AvisynthPlus, this plugin is a MT_NICE_FILTER (automatic register, no need to call SetFilterMtMode).
With AvisynthMT, SetMtMode(1) must be called before SmoothAdjust.



VI. USAGE :
===========

- SmoothLevels( input_low, gamma, input_high, output_low, output_high, chroma, limiter, TVrange, preset,
Lmode, darkSTR, brightSTR, Ecurve, Ecenter, protect,
interp, dither, HQ, useMT, useOPT, debug, screenW, screenH, scale )

- SmoothTweak( brightness, contrast, saturation, hue1, hue2, limiter, TVrange,
Lmode, limitSTR, Ecenter,
interp, dither, HQ, useMT, useOPT, debug, screenW, screenH, scale )

- SmoothCurve( Ycurve, Ucurve, Vcurve, mode, limiter, TVrange,
interp, dither, HQ, useMT, useOPT, debug, screenW, screenH, scale )

- SmoothCustom( Yexpr, Uexpr, Vexpr, limiter, TVrange,
interp, dither, HQ, useMT, useOPT, debug, screenW, screenH, scale )

- SmoothTools( filename,
interp, dither, HQ, useMT, useOPT, debug, screenW, screenH, scale )

- SmoothLevels16(...), SmoothTweak16(...), SmoothCurve16(...), SmoothCustom16(...), SmoothTools16(...) for 16 bits


Last version (2015/11/15): SmoothAdjust v3.20 (http://latoninf.free.fr/d9/SA/SmoothAdjust-v3.20.7z)

Old version (for Avs2.5 or WinXP or Wine): SmoothAdjust v2.62 (http://latoninf.free.fr/d9/SA/SmoothAdjust-v2.62.7z)


If you really like this filter, please consider donating...
It will help me a lot to continue development and support.
Thanks for all! (link in the .7z package)


v3.20:
updated for Avs v2.6.0 final
fixed AVX2 crash with Win7 without SP1

v3.00:
dropped Avs v2.5.x support
added AVX2 code (10% faster)
modified plugin to be thread-safe (MT_NICE_FILTER)

v2.95:
fixed minor things
tweaked multi-threading code

v2.90:
fixed possible freeze in MT code
added explicit error messages

v2.85:
fixed bugs inside multi-threading code
removed user32 dependency
added AVX2 detection (for future opt)

v2.80:
used new C++11 features
rewritten multi-threading (native)
speed optimization (40% faster)
exception-safe code
added a high quality interpolation mode
changed some parameter names
fixed bugs in SmoothTools parser

v2.62:
fixed minor things & bugs
dropped ICL builds support

v2.60:
used new interface for v2.6.x builds

v2.55:
added small optimizations

v2.51:
fixed crash in SmoothCurve

v2.50:
added SmoothTools
improved SmoothTweak
improved dithering
tweaked memory usage
tweaked multithreading
cleaned various stuff

v2.00:
added Avisynth 2.6.x support
added Y8, YV411, YV16, YV24 support
added 16bits support with stacked MSB/LSB
added SmoothCustom filter
added TVrange parameter
added AVX optimization

improved smoothing algorithm
improved debug view
improved startup delay
improved speed with smoothing OFF

added decimals support in SmoothCurve
fixed interp scaling in SmoothCurve
changed defaults in SmoothLevels
fixed gamma clamping bug in SmoothLevels

fixed crash with mod4 clip
fixed freeze in debug view
deleted Smode parameter
switched from ICL11 to ICL12
cleaned a lot the code
updated the documentation


_

LaTo
5th June 2010, 14:43
Screenshots of SmoothCurve(show=true) & SmoothLevels(show=true):

http://latoninf.free.fr/d9/SA/SCshow_mini.png (http://latoninf.free.fr/d9/SA/SCshow.png)
* SmoothCurve - Click the image to enlarge *

http://latoninf.free.fr/d9/SA/SLshow_mini.png (http://latoninf.free.fr/d9/SA/SLshow.png)
* SmoothLevels - Click the image to enlarge *

Gavino
5th June 2010, 15:23
Excellent LaTo, many thanks.

Can you clarify one thing.
Are the 'curves' in SmoothCurve composed of linear segments, or is some sort of non-linear interpolation (eg spline) done?
This example suggests linear.

"0-0;16-0;235-255;255-255" = TV to PC conversion

LaTo
5th June 2010, 15:26
Excellent LaTo, many thanks.

Can you clarify one thing.
Are the 'curves' in SmoothCurve composed of linear segments, or is some sort of non-linear interpolation (eg spline) done?
This example suggests linear.

Yes it's only linear at this time :)

Keiyakusha
5th June 2010, 15:50
So now we have a plugin. Nice, thank you!

P.S.
Oh, I know, I know what we need now -> LSFmod 2.0 -> super fast asm-optimized plugin from LaTo ^__^

LaTo
5th June 2010, 15:56
So now we have a plugin. Nice, thank you!

P.S.
Oh, I know, I know what we need now -> LSFmod 2.0 -> super fast asm-optimized plugin from LaTo ^__^

SmoothAdjust is only C code :p

It's on my todo list to add asm code, but before... I need to learn asm :eek:

elguaxo
5th June 2010, 16:06
Thanks!

Keiyakusha
5th June 2010, 17:53
SmoothAdjust is only C code :p

Oh really? So such speedup only because of avs -> C port... So (probably) there is still place for improvements.

P.S.
Well, then super fast not asm-optimised LSFmod 2.0 from LaTo will be fine! :)

MatLz
5th June 2010, 19:57
Un grand merci !
I have to wait to test the dithering part of your plugin...
Can it contain a 'shift' of the space like using a combination of different extra mirrored pixels for gradfun2db ? (Like 32 + 28)

LaTo
5th June 2010, 20:04
Can it contain a 'shift' of the space like using a combination of different extra mirrored pixels for gradfun2db ? (Like 32 + 28)
I didn't understand your question but the dithering inside is different from gradfun2db.
GradFun2DB removes band in a video, but this one only prevents banding... So if the banding is already present in the clip, it will not remove it!
It's not the same goal :)

MatLz
6th June 2010, 14:51
I didn't understand your questionYeah...my english is so limited :D

Maybe you will better understand if you read my two posts in this page :
http://forum.doom9.org/showthread.php?t=152127&page=25

(I hope you will ;) )

LaTo
6th June 2010, 14:53
Yeah...my english is so limited :D

Maybe you will better understand if you read my two posts in this page :
http://forum.doom9.org/showthread.php?t=152127&page=25

(I hope you will ;) )

Ok, it's to remove the edge/border issue?

MatLz
6th June 2010, 15:00
Yes and no, this problem is known since a long time now but mirroring a different number of pixels doesn't give the same effect.
And the combination of the two, in serial or parallele, gives really nice results

LaTo
6th June 2010, 15:03
Yes and no, this problem is known since a long time now but mirroring a different number of pixels doesn't give the same effect.
And the combination of the two, in serial or parallele, gives really nice results

OK, maybe an addition to GF2mod, I will look at this later :)

MatLz
6th June 2010, 15:13
OK, maybe an addition to GF2mod, I will look at this later :)Nice!
(When you will have the time to look at that, don't hesitate to pm me, in french of course :D, to explain me what is the 'technical' reason of these differences)
Thanks.

LaTo
6th June 2010, 17:08
Someone could test this x64 version please? SmoothAdjust-x64.dll (http://latoninf.free.fr/d9/SA/SmoothAdjust-x64.dll)

Didée
6th June 2010, 19:39
Did only a very quick splash&go test, but the x64 dll it seems to work. (Calling all three filters with default() parameters.)

More later - a thunderstorm is coming up, I'll shut down now.

Didée
6th June 2010, 22:47
So far, everything seems to work. No crashes, no garbled output. It works. :)

However, it seems that the dithered-smoothing operation could need a little more work. Example: Pretty dark Intro of an average DVD show. Target operation: Levels(16,2.6,235,0,255,false).

Source frame:
http://img96.imageshack.us/img96/5103/sourceframe.th.png (http://img96.imageshack.us/i/sourceframe.png/)

Results:
http://img709.imageshack.us/img709/8487/smoothadjustlevels.th.png (http://img709.imageshack.us/i/smoothadjustlevels.png/)

The smoothing of the dark blocking isn't as effective as gradfun2db. Also, there is a problem at high-contrast transitions.

(Sorry I didn't cross-check if it's the same with the 32bit build ... funnily, on the new machine the Avisynth64 setup is more complete then the 32bit counterpart...)

LaTo
7th June 2010, 07:09
v1.02:
added x64 build
fixed a bug in SmoothLevels

LaTo
7th June 2010, 07:13
So far, everything seems to work. No crashes, no garbled output. It works. :)

However, it seems that the dithered-smoothing operation could need a little more work. Example: Pretty dark Intro of an average DVD show. Target operation: Levels(16,2.6,235,0,255,false).

Source frame:
http://img96.imageshack.us/img96/5103/sourceframe.th.png (http://img96.imageshack.us/i/sourceframe.png/)

Results:
http://img709.imageshack.us/img709/8487/smoothadjustlevels.th.png (http://img709.imageshack.us/i/smoothadjustlevels.png/)

The smoothing of the dark blocking isn't as effective as gradfun2db. Also, there is a problem at high-contrast transitions.

(Sorry I didn't cross-check if it's the same with the 32bit build ... funnily, on the new machine the Avisynth64 setup is more complete then the 32bit counterpart...)

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 :)

LaTo
7th June 2010, 14:16
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 ?

LaTo
14th June 2010, 16:02
v1.16:
replaced Smode 3 & 4 with stronger smoothing function
changed minors things

About Smode:
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).

carlmart
19th June 2010, 13:55
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/n4w5zu5ezjl/contrast#1.jpg

LaTo
19th June 2010, 15:50
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/n4w5zu5ezjl/contrast#1.jpg

Lmode=1 should be useful for your clip:
SmoothLevels(gamma=1.6,Ecenter=32,Lmode=1)

Tweak gamma (around 2.0) for intensity and Ecenter (between 32 & 64) for best looking.

VincAlastor
21st June 2010, 18:08
thank you lato, smoothadjust is much faster than smoothlevels!

LaTo
21st June 2010, 18:32
v1.18:
tweaked Smode 3 & 4
updated avisynth header

:)

Blue_MiSfit
21st June 2010, 21:32
Nice! Your scripts are AWEOSME, LaTo! I use SmoothLevels quite frequently so any update or additional functionality is enthusiastically welcomed!

Derek

Bi11
27th June 2010, 04:17
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:
http://img80.imageshack.us/img80/7598/0255.png

Using SmoothLevels(preset="pc2tv") gives the histogram below:
http://img687.imageshack.us/img687/1513/16235.png

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:
http://img205.imageshack.us/img205/1306/adjusted.png

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.

LaTo
27th June 2010, 10:06
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:
http://img80.imageshack.us/img80/7598/0255.png

Using SmoothLevels(preset="pc2tv") gives the histogram below:
http://img687.imageshack.us/img687/1513/16235.png

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:
http://img205.imageshack.us/img205/1306/adjusted.png

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?

Bi11
27th June 2010, 22:50
I want something like:
# 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.

Didée
27th June 2010, 23:48
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] :

mt_lut("x 8 < x 2 * x 247 > 255 255 x - 2 * - x 8 - 247 24 - 247 8 - / * 16 + ? ?",U=2,V=2)

Gavino
28th June 2010, 00:02
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
mt_lut("x 8 < x 2 * x 247 > 255 255 x - 2 * - x 8 - 239 16 - 247 8 - / * 16 + ? ?",U=2,V=2)

Didée
28th June 2010, 00:45
No ... I was meaning
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.

Bi11
28th June 2010, 01:12
... with fixed values to spread [0-8]>[0,16] and [247,255]>[239,255] :

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:
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: http://img514.imageshack.us/img514/8640/orig.png Code above: http://img42.imageshack.us/img42/4494/mtlut235.png

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.

Didée
28th June 2010, 07:44
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 (http://www.lagom.nl/lcd-test/white.php) - do you see "everything"?


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.:)

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".

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 ...

Bi11
28th June 2010, 08:42
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 (http://www.lagom.nl/lcd-test/white.php) - 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.
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).
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.
:thanks:

Didée
28th June 2010, 09:40
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.

Gavino
28th June 2010, 10:04
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:
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+" + ? ?")
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, ...)")

Didée
28th June 2010, 10:31
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. :D

LaTo
28th June 2010, 18:43
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?

LaTo
4th July 2010, 17:32
v1.24:
added new interpolation mode for SmoothCurve (see interp)

LaTo
4th July 2010, 17:33
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 :cool:

markanini
4th July 2010, 21:08
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?

royia
5th July 2010, 07:46
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.

LaTo
5th July 2010, 08:09
One easy way would be looking at Matlab's code for Splines.

Thanks but it's already in v1.24 ;)

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:

source=last
process=source.bilateral().noise()
mt_lutxy(source,process,"x 250 >= y x ?",chroma="copy")
SmoothLevels(gamma=0.06,Smode=3)


:devil:

LaTo
5th July 2010, 14:25
v1.26:
Smode=3 is now the default (instead of Smode=1)
tweaked smoothing sensitivity
updated documentation about Smode

markanini
5th July 2010, 18:49
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? :D

LaTo
5th July 2010, 18:54
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? :D

And with Smode=4? Results should be much better for high strength.

markanini
9th July 2010, 09:53
@ 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.

Emulgator
13th July 2010, 15:32
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 !