View Full Version : Hdr Agc 1.8.7 - 10.09.2006
paviko
25th April 2005, 22:11
HDR AGC version 1.8.7
More info and download at my homepage (http://strony.aster.pl/paviko/)
-----
MODERATOR Note: This link is dead. Use this one:
https://web.archive.org/web/20131018094707/http://strony.aster.pl/paviko/hdragc.htm
-----
High Dynamic Range Automatic Gain Control - this plugin increase dynamic range of video clips (enhance shadows). It's "simply" gaining (brightening) dark areas of image without causing blow of highlights and is doing it by simulating the work of our eyes. Amount of gain is calculated automatically but you can also influence on it by parameters.
This plugin support YV12 and YUY2 color sprace.
Usage:
AVISource(...)
SeparateFields() # if content is interlaced
HDRAGC()
Weave() # if content is interlaced
MOST IMPORTANT PARAMETERS:
coef_gain (default 1.0) - increase parameter to get brighter image, decrease to limit auto brightening
coef_sat (1.0) - incerease to bring more saturation
TODO for 2.0 version
- MMX, SSE, SSE2 optimization
Tips:
1. I'd like to have brigther results.
Try increasing coef_gain and/or min_gain
2. Image lacks colours saturation after brightening
Try increasing coef_sat parameter
3. I would like to operate only in luma (without changing chrominance channels)
Set max_sat to 1.0
4. When I set coef_sat lower that 1.0, bright area of image are loosing saturation
Set min_sat to 1.0 (default value id 0.0)
5. Bright areas of image are too much gained
Try corrector parameter - recommended values are (0.8 - 1.0), the lower value then less gain is applied to brighter part of image
6. Gained parts have too much noise
Try increasing reducer parameter. Default value is 0.5, max is 2.0
morsa
26th April 2005, 09:34
Wow. I always like this kind of things!!!!!
videoFred
26th April 2005, 13:47
Congratulations!
This filter looks very, very promising.
Could this be a real auto-levels filter at last?
Is it possible to add an auto-gamma setting too?
Fred.
Mug Funky
26th April 2005, 16:53
kickass! this could really help with the Zion scenes in the matrix trilogy (baaad lighting ratio right thurr).
not sure if it'll help on some grainy-as-hell and dark DV footage i have, but i don't expect anything to save that.
i think i'll wait for some optimization - i'm running a 5 year old machine, so every cycle is sacred.
[edit] i can see this becoming very useful for avisynth 3, if it ends up supporting 16bpc video - HDR is best suited to more-than-8-bits.
hehe. i'm a bit of an HDR fan - i've even got one of those mirror-ball light-probe things, though i hardly use it anymore (it's warped at the seam...).
paviko
26th April 2005, 17:58
@videoFred
Is it possible to add an auto-gamma setting too?
Why would you like to auto control gamma?
Gamma is causing some contrast loss, that's why HDR technics were invented to overcome this.
But maybe it can be usefull. Could you describe in more detail how you imagine the gamma control? Of course the best would be image examples showing diffrent situations ;)
@Mug Funky
this could really help with the Zion scenes in the matrix trilogy (baaad lighting ratio right thurr) This plugin works best with low compressed input like DV stream, where lots of details are preserved in dark areas. I don't know if MPEG2 isn't too lossly compression (depends on how the film was compressed). The more compressed input then less gain would be possible without artefacts.
not sure if it'll help on some grainy-as-hell and dark DV footage i have
I've done this plugin for my home DV shoots (birthdays, etc.) :) Of course without good denoiser (fortunately we've got here the best ones: MVTools, FFT3D) we can't do much. But today mainstream camcorders (eg. Pana GS-120, Sony HC-85, Canon Optura) easily handle gain as much as 3.0 times.
Those examples posted by me are from Panasonic GS200, Sony PC350 and Sony PC85.
i can see this becoming very useful for avisynth 3, if it ends up supporting 16bpc video - HDR is best suited to more-than-8-bits.
Yes but when we will be able to touch devices recording in 16-bit format ;)
Regards
Backwoods
27th April 2005, 04:05
http://img235.echo.cx/img235/4666/wall05fe.jpg
HDRAGC(max_gain=1.5)
Awesome filter.
AVIL
27th April 2005, 06:18
Felicitations. This is an superb filter.
I've done a benchmark with virtualdub's filter "MSU Smart Brightness & Contrast" and the result is favourable to your filter. Your image has no halos, better contrast and less pixelation in dark areas.
Only one doubt. I've tried with different values (from 16 to 255) for avg_lum but with no visual changes at all. ¿Do this parameter depend on others?
I often process VHS captures (YUY2 colorspace). I can accept promote to RGB. The return to YUY2 is almost lossless. The return from YV12 isn`t lossless. Despite the evolution to YV12 ¿It will be possible to preserve RGB processing in future releases?.
Thanks.
videoFred
27th April 2005, 07:24
Originally posted by paviko
@videoFred
Why would you like to auto control gamma?
Gamma is causing some contrast loss, that's why HDR technics were invented to overcome this.
But maybe it can be usefull. Could you describe in more detail how you imagine the gamma control? Of course the best would be image examples showing diffrent situations ;)
I did a very first test on some very dark files and the result was even better if I increased the gamma with VDub. But this was a very first and promising test on some divX files. At home, I have tons of huge 1024x768 Huffyuv files, and a fast computer. I do some more testing, and report the results here, but I need at least a week for this. ;)
Fred.
Didée
27th April 2005, 14:14
paviko, this is very nice work. A little sluggish ;) , but results are really impressing!
It reminded me of the fact that in one of my postponed scripting projects, there is some code gathering dust for half a year now, that tries to do something rather similar. (Namely: the "contrast booster" feature of "LimitedSharpen-EX".)
The principle of operation is less sophisticated and precise (general limitations of AviSynth scripting). In exchange, it runs somewhat faster than HDRAGC() ... 10 times, or more.
Result when feeding the "lowlight" JPEG from above as input, via imagereader:
http://img199.echo.cx/img199/300/lsharpenexconenh1mw.th.jpg (http://img199.echo.cx/my.php?image=lsharpenexconenh1mw.jpg)
If someone is interested in the (unfinished) AVS code, drop a line here. Basically, an ultra-wide gaussian blur is done, then the difference to the original is square-rooted, and fed into a modified multiplication/hardlight routine.
(Should I think about writing PDF whitepapers ...) ;)
joshbm
27th April 2005, 14:48
Didee I am interested. I am also interested in LimitedSharpen-EX ;-).
paviko
27th April 2005, 18:12
Thank you all for your replies.
@AVIL
Only one doubt. I've tried with different values (from 16 to 255) for avg_lum but with no visual changes at all. ¿Do this parameter depend on others?
Thank you for reporting this. It's a bug, avg_lum parameter is partially reversed in code now, so it's definitaly not working as it's supossed to work.
¿It will be possible to preserve RGB processing in future releases?. RGB32 will be always supported in this plug-in. Gaining in RGB space is not causing loss of saturation. I haven't tried yet solving equation for YUV colour format, so I don't know if the plug-in will work the same in YUV, but it will be faster. It's also possible that YUY2 version will be added too.
@videoFred
Thanks, waiting for your reports :)
@Didée
it runs somewhat faster than HDRAGC() ... 10 times, or moreI'm planning to optimize these filter, don't know exactly how much faster it will run. Probably the ultra-wide gaussian you are using is highly optimized by avisynth developer team. In my plug-in the most computational task is calculating average brigthness with inclusion of simulating human eye reaction (should I believe what is written in this article ? ;) ) - it's like reading one frame of video 150 times.
If someone is interested in the (unfinished) AVS code, drop a line here. Basically, an ultra-wide gaussian blur is done, then the difference to the original is square-rooted, and fed into a modified multiplication/hardlight routine.
Yes please post it Didée, I'm especially interested in your "modified multiplication/hardlight routine" :)
Should I think about writing PDF whitepapers ... Definately yes :)
Regards
tsp
28th April 2005, 00:15
paviko: I took a look at you code and did a little profiling on it. it seems if it's this loop that's taking about 75% of the time:
for (h=0; h < src_height;h++) { // Loop from bottom line to top line.
for (w = 0; w < src_width/4; w++) { // and from leftmost pixel to rightmost one.
int miny = h - circle;
if (miny < 0)
miny = 0;
int maxy = h + circle;
if (maxy > src_height - 1)
maxy = src_height - 1;
int minx = w - circle;
if (minx < 0)
minx = 0;
int maxx = w + circle;
if (maxx > src_width / 4 - 1)
maxx = src_width / 4 - 1;
y_local[h][w] = 0.0f;
float w_sum = 0.0f;
for (int y = miny; y <= maxy; y++)
for (int x = minx; x <= maxx; x++){
if (circleMat[w - x + circle][h - y + circle]){
float weight = weights[y_lum[y][x]][y_lum[h][w]];
w_sum += weight;
y_local[h][w] += weight * y_lum[y][x];
}
}
y_local[h][w] /= w_sum;
}
}
I changed it to this and gained about 25% speed increase:
for (h=0; h < src_height;h++) { // Loop from bottom line to top line.
int miny = h - circle;
if (miny < 0)
miny = 0;
int maxy = h + circle;
if (maxy > src_height - 1)
maxy = src_height - 1;
for (w = 0; w < src_width/4; w++) { // and from leftmost pixel to rightmost one.
int minx = w - circle;
if (minx < 0)
minx = 0;
int maxx = w + circle;
if (maxx > src_width / 4 - 1)
maxx = src_width / 4 - 1;
//y_local[h][w] = 0.0f;
float y_local_h_w=0.0f;
float w_sum = 0.0f;
int y_lum_hw=y_lum[h][w];
for (int y = miny; y <= maxy; y++)
for (int x = minx; x <= maxx; x++){
if (circleMat[w - x + circle][h - y + circle]){
int y_lum_xy=y_lum[y][x];
float weight = weights[y_lum_xy][y_lum_hw];
w_sum += weight;
y_local_h_w += weight * y_lum_xy;
}
}
y_local[h][w] = y_local_h_w/w_sum;
}
}
Else a very nice filter.
Yuri
28th April 2005, 04:43
Unfortunately, I only get a green screen when I load this filter through VDub. Why so? What am I doing wrong?
Backwoods
28th April 2005, 05:23
Do you have "ConvertToRGB32()" before the filter's functions?
Yuri
28th April 2005, 14:51
Now it works!
Thank you, Backwoods.
Bordo32
28th April 2005, 18:33
@paviko, very nice and promising filter :cool:
Just a thought, if by using AVISource(...) DV codec opens avi file in YUY2 space, the next line ConvertToRGB32() will expand luma from 16-235 range to 0-255. All details below 16 and above 235 will be lost. We know that most of miniDV cams have overshoots in luma up to 255.
Would it be better use:
ConvertToRGB(matrix="PC.601") and have a full luma range?
It might be stupid question, but I am just curious, is this filter is interlaced aware, does not require those SeparateFields() Weave() type of things?
Wilbert
28th April 2005, 19:34
Would it be better use:
ConvertToRGB(matrix="PC.601") and have a full luma range?
Yes, you can try that. Best is to compare both and see what you like best.
It might be stupid question, but I am just curious, is this filter is interlaced aware, does not require those SeparateFields() Weave() type of things?
Nope, because the avi is opened as YUY2 (you only need it if source or target is YV12).
paviko
28th April 2005, 22:19
@backwoods
I've looked closer to your frame grab and I'd like to have you camcorder :eek: It's perfectly keeping colour information in dark areas. Is it a professional camcorder? The best result with such a good devices can be obtained when max_sat parameter is set to 1.0. Otherwise colours can be boosted too much.
@tsp
Thank you very much for your help, it definately should be like you posted.
@Bordo32
the next line ConvertToRGB32() will expand luma from 16-235 range to 0-255I've never thought about this, because I've instaled DV codec that is using 0-255 range. I think that ConvertToRBG will leave 16-235 range unchanged but not sure and for now can't check it. Of course you should listen to Wilbert ;)
Thanks for pointing it, I'll addres the issue with the range 16-235 when YUY2 support will be added.
It might be stupid question, but I am just curious, is this filter is interlaced aware, does not require those SeparateFields() Weave() type of things? It's your second ;) perfect question. It's best to do separatefields() and then weave() for interlaced. But also without it only in special cases some artefact can appear. Maybe it's good to add interlaced mode to filter, or do you prefer doing it yourself with separatefields() and weave() ?
Regards
Backwoods
29th April 2005, 00:22
Originally posted by paviko
@backwoods
I've looked closer to your frame grab and I'd like to have you camcorder :eek: It's perfectly keeping colour information in dark areas. Is it a professional camcorder? The best result with such a good devices can be obtained when max_sat parameter is set to 1.0. Otherwise colours can be boosted too much.
Ah yes, I didn't notice that max_sat was 2.0 by default. Putting it around 1.5/6 gives a nice result. And the camera I was using is a Sony HDR-FX1, nice camera.
It's your second ;) perfect question. It's best to do separatefields() and then weave() for interlaced. But also without it only in special cases some artefact can appear. Maybe it's good to add interlaced mode to filter, or do you prefer doing it yourself with separatefields() and weave() ?
I would just put a note in saying to use SeparateFields() and Weave() for interlaced people. Considering those people are going to be doing other effects also, which should be done inbetween S() and W(). Unless it's easy enough to code interlaced material handling.
Wilbert
29th April 2005, 09:24
It might be stupid question, but I am just curious, is this filter is interlaced aware, does not require those SeparateFields() Weave() type of things?
Nope, because the avi is opened as YUY2 (you only need it if source or target is YV12).
Oops :) I completely misunderstood your question.
paviko
29th April 2005, 21:25
New, small update to version 0.1.1.
1. New parameter "circle" allows to increase speed 4 times with some little quality loss. Default value is 7, but you can go as low as 3.
2. Fixed bug with avg_lum (thanks to AVIL)
3. C optimization (thanks to tsp)
4. Other new parameters: coef_gain and min_sat.
@Backwoods
I was using is a Sony HDR-FX1, nice camera.
You're lucky :)
Regards
Bordo32
29th April 2005, 22:58
@paviko, about the 0-255 range, my point is that even your DV codec uses 0-255 range, and assuming it opens avi in YUY2 range (not such Panasonic -RGB only type codec), ConvertToRGB expands YUY2 luma from 16-235 to RGB 0-255 values. In this scenario all details above 235 luma will be lost. This is the common miniDV cam problem, even Sony HDR-FX1 which has a "zebra" function. Using cams with no "zebra" (such Sony HC-85) complicates situation even more.
By using ConvertToRGB(matrix="PC.601") you convert YUY2 from 0-255 to RGB 0-255 range (not 16-235 to 0-255) preserving all overshoot values above 235. Now you retain the original full luma range. If HDR AGC filter could do all the work in 0-255 range and finally keep (reduce) RGB values to 16-235 range would be perfect solution.
My final target is DVDR, so my next step is frameserving *.avs to video editor (Vegas for example, which works correctly with full RGB range) editing and encoding to mpeg2.
I'll addres the issue with the range 16-235 when YUY2 support will be added.
I would say it is nothing to do with the YUY2 support, luma already might be out of 16-235 luma range, right from original YV12 color space avi file (assuming it is taken from miniDV cam.).
It would be perfect if you could address all full RGB range and interlaced material handling related issues.
Thanks.
Backwoods
30th April 2005, 07:32
Originally posted by paviko
1. New parameter "circle" allows to increase speed 4 times with some little quality loss. Default value is 7, but you can go as low as 3.
What type of quality loss? Loss of color/contrast/detail?
Of course I will test this new version all day tomorrow, great stuff.
paviko
30th April 2005, 23:02
@Bordo32
ConvertToRGB expands YUY2 luma from 16-235 to RGB 0-255 values. In this scenario all details above 235 luma will be lost If luma is only in range 16 to 235, then there is no information between 235 and 255 so expanding to 0-255 will only give more contrast (image doesn't look washed out). But maybe you mean that displaying it on TV will cause details loss? I can't find what's happening when encoding clip to MPEG2 :(
@Backwoods
What type of quality loss? Loss of color/contrast/detail?
It's a loss of contrast for small details - small details are less distinguish from background by decresing circle value (hmm it should rather be named radius by me, not circle ;) )
Version 0.1.2 alpha
I've found some low-light clips that behaves strangly. They have luma in range 0-80 and only gain to 0-150 with very plastic look. In new version I've changed lightness distribution routine to fix this problem. Now midtones also have higher contrast.
New value for auto control of saturation - coef_sat can be 0.0 which means that max_sat will be applied to pixels that get max_gain, other pixels get saturation respectivaly to their gain.
Calculated gain is independent of avg_lum parameter, so changing avg_lum won't change drastically gain for dark areas.
Link to HDR AGC 0.1.2 (http://www.klient.neostrada.pl/HDRAGC0.1.2.zip)
Regards
guada 2
1st May 2005, 14:26
I appreciate this beautiful work. :)
But a question challenges me.
The human eye is able to observe the chromatic apects of its environment. With this optimization would not be it not worrying to raise the question of this filter about zones of shades and dark of a realistic scene.
Nevertheless on the strategic level of defense (thorough war/investigations), this filter will be a considerable investment.
trolltuning
1st May 2005, 18:11
Can anyone do slightly better with this dark source?
http://members.atlantic.net/~andypo/go/compar~1.jpg
By the way this is a great plugin and maybe an unfair test.
(originally DV footage)
I tested this with the following script:
Avisource("D:\capture\Swdark.avi")
ConverttoRGB32()
#HDRAGC(avg_lum= 1000,max_gain =3.8, min_gain=2.8, coef_gain=1.0)
HDRAGC(max_gain =5.8, min_gain=4.8, coef_gain=2.5,max_sat=1.6)
and compared with the original:
vid1=Avisource("D:\capture\Swdark.avi")
vid2=Avisource("D:\avis\Hadrag1.avi")
vid2=vid2.converttoRGB32
stackhorizontal(vid1,vid2)
reduceby2()
Mug Funky
2nd May 2005, 10:36
If luma is only in range 16 to 235, then there is no information between 235 and 255 so expanding to 0-255 will only give more contrast (image doesn't look washed out). But maybe you mean that displaying it on TV will cause details loss? I can't find what's happening when encoding clip to MPEG2
true in theory, but in practice a lot (i mean a LOT) of DV cameras will capture outside the 16-235 range - not so much in the black end, but certainly in the super-white end.
it would be nice to have this extra bit of detail, as it's often the difference between "hot" and "overexposed".
[edit]
FWIW, pinnacle's old DV25 codec will decode DV to rgb24 and keep the luminance how it was captured, at the cost of slow speed (it's old) and slight blurring (i don't know where that comes from, probably the rgb conversion).
paviko
2nd May 2005, 11:15
@guada 2
The human eye is able to observe the chromatic apects of its environment. With this optimization would not be it not worrying to raise the question of this filter about zones of shades and dark of a realistic scene.
Can I read somewhere about "zones of shades and dark of realistic scene" or maybe you can explain it in more detail? Currently in plug-in saturation can be controled so some aspects of chromatic information is processed.
@trolltuning
Can anyone do slightly better with this dark source?
What would you like to improve?
If you want it to be more bright then simply use:
HDRAGC(max_gain = 12.0)
If it's too bright lower max_gain.
If you want to play with colours you need to white balance the scene (remove probably the yellow) and increase the max_sat value to the level you like:
HDRAGC(max_gain = 12.0, max_sat = 3.0, coef_sat = 0.0)
Probably with colours can't be done much - too dark scene for camcorder to keep them.
@Mug Funky
in practice a lot (i mean a LOT) of DV cameras will capture outside the 16-235 range - not so much in the black end, but certainly in the super-white end.
it would be nice to have this extra bit of detail, as it's often the difference between "hot" and "overexposed".
So how it would be the best to procces it. Doing ConvertToRGB(matrix="PC.601") will preserve those ranges as I assume and now allready HDR AGC will expand all information to 0-255 (so if it was allready beyond 235 in YUY2 then it won't be lost). Or maybe it should be better to keep everything in 16-235 range by HDR AGC even squeeze these additional information that was beyond range orginally?
Regards
Bordo32
2nd May 2005, 18:44
@paviko,
Or maybe it should be better to keep everything in 16-235 range by HDR AGC even squeeze these additional information that was beyond range orginally?
This would be good approach.
Or HDR AGC my work in 0-255 RGB range and RGB values
might be reduced to 16-235 after all work is done.
I guess for such a dark scene, only way will be to have the colorization filter E-male is trying to develop :)
Backwoods
3rd May 2005, 22:50
Originally posted by morsa
I guess for such a dark scene, only way will be to have the colorization filter E-male is trying to develop :)
which is that?
videoFred
9th May 2005, 11:48
Paviko,
*EDIT: I changed my opinion about the saturation, see my other posting below.*
I did many tests, this weekend.
It appears to me your first version is better...
The second one gives too much saturation.
But this is a problem with the first one, too.
There is too much saturation, and I can not reduce this with max_sat=1. Also, colors are a little unnatural.
However, this amazing filter still looks very promising to me.
I already can use it. I reduce saturation and adjust contrast a little afterwards.
On German broadcast, I saw a film and I am almost sure they used the same principles as you do (maybe in the camera?). Contrast was very equal, colors where very vivid. Awesome!
I sure hope you have time to develop it further!:thanks:
Together with Fizicks depan plugin, your plugin could be my favorite!
You are almost there, we just need some more fine-tuning.
Maybe you could make saturation more adjustable?
EDIT: But I was thinking... I'm not a colorspace-codec expert.
Could the saturation problem be caused by the Huffyuv codec I use?
I'm gonna do some more tests with the Panasonic DV codec.
Maybe it is not a saturation, but colorspace issue, right?
Any other people who are testing this filter?
Fred.
paviko
9th May 2005, 21:49
It appears to me your first version is better...
The second one gives too much saturation.
But this is a problem with the first one, too.
There is too much saturation, and I can not reduce this with max_sat=1. Also, colors are a little unnatural.
Strange that max_sat=1 brings more saturation, because with value 1 it turns off completely any saturation code. Maybe you mean brightness. In second version overall brightness was a bit higher for the same settings. The best ofcourse would be if you could post pre and post images. It will help also in tuning.
I sure hope you have time to develop it further! Not much time but I'll develop it further slowly. Now I'm thinking of completely diffrent algorithm of HDR which is matematically beautyfull ;) It needs a lot of time to implement, because I'll have to probably code myself partial differential poisson equation solver. Using available tools I've found, one frame will take 360 GB !!! of memory :eek
Maybe you could make saturation more adjustable?
Have you tried coef_sat setting to 0.0 and then playing with max_sat starting from 1.0 ?
I'm not a colorspace-codec expert.
Could the saturation problem be caused by the Huffyuv codec I use?
I have no idea about Huffyuv :confused: but rather it can't cause bad things I think.
Regards
Fizick
10th May 2005, 00:34
paviko,
Sorry, but i still did not try your plugin.
But do you take into acount the temporal variations?
Some time ago i made Deflicker plugin for brigthness and contrast temporal stabilizing.
What do you think about it? May be some combination is possible?
videoFred
10th May 2005, 06:52
Originally posted by paviko
Strange that max_sat=1 brings more saturation, because with value 1 it turns off completely any saturation code. Maybe you mean brightness. In second version overall brightness was a bit higher for the same settings. The best ofcourse would be if you could post pre and post images. It will help also in tuning.
Thank you for the answers!
I did more testing, your colors are OK! Also on version 2.
I can play with the sigma parameter also, I was forgatten to use this parameter :confused:
Now, together with max_gain, min_gain, avg_lum I can do miracles with this filter.
And no, it has nothing to do with the used codec or colorspace.
As soon as possible, I post some results.
Aaaahhh! I would like to run this filter on several hundred files in batch, without the need to do settings for each individual file!
Am I dreaming? Would this be possible? :confused:
Fred.
E-Male
10th May 2005, 18:43
Originally posted by Backwoods
which is that?
no public release, yet
i'm done porting Ming Yang's code, but i'm still working on interfaces
also i daubt this will help much here
AFAIK the algo needs 'good' luma to correctly spread the colors
Backwoods
11th May 2005, 01:42
Originally posted by videoFred
Aaaahhh! I would like to run this filter on several hundred files in batch, without the need to do settings for each individual file!
Am I dreaming? Would this be possible? :confused:
How are your files named? You can load them into AVISynth with ImageSource and then use ImageWriter if you wanted them as images again (or just export them as images from VirtualDub).
videoFred
11th May 2005, 06:41
Originally posted by Backwoods
How are your files named? You can load them into AVISynth with ImageSource and then use ImageWriter if you wanted them as images again (or just export them as images from VirtualDub).
No,no!
I mean AVI files, not stills.
Fred.
videoFred
11th May 2005, 06:56
Originally posted by Fizick
paviko,
Sorry, but i still did not try your plugin.
But do you take into acount the temporal variations?
Hi Fizick,
You realy should try it, because I understood you also are working with old 8mm film, right? Then you know how difficult it is to capture high contrast scenes. Almost always the whites are overexposed. Not on the original, but on the digital capturing.
The very best way to deal with this is double capturing: then you have a bright and a dark clip of the same scene. With overlay() and a mask, I put them together again, and then I realy see everything that is on the film. But this all takes a lot of time.
Another method is: if you expose on the highlights while capturing, you end up with a very dark picture, but with correct highlights. But there is still much information in the dark parts, and this filter makes this visible. Yes, as far as I can see, it deals also very well with temporal variations.
Btw: Your 15/25fps script works very well! It gives very smooth pannig! Awesome to see how it realigns every frame. I use it all the time for panning scenes.:cool:
Fred.
Backwoods
11th May 2005, 08:42
Originally posted by videoFred
No,no!
I mean AVI files, not stills.
Fred.
You can either use SegmentedAVISource (which I'm sure you know of already), if not, there is a Java based program that would create a script for every AVI in a DIR. Where do you find it? I forget, it was posted ages ago.
videoFred
11th May 2005, 11:31
Originally posted by Backwoods
You can either use SegmentedAVISource (which I'm sure you know of already), if not, there is a Java based program that would create a script for every AVI in a DIR. Where do you find it? I forget, it was posted ages ago.
Hello Backwoods again!
Thank you for your suggestions, but I must make myself more clear.
Here we go: as you know, I transfer old 8mm films. I use a 1024x768 machine vision camera for this, and capture with Huffyuv. Framerate of these files is 15fps. But even a short 3min. reel of 8mm film contains several, very different scenes. Thus I capture these scenes as seperate AVI's, max.1000 frames.
With the HDR filter, each scene needs other filter settings, it makes no sence if I edit them in batch with the same filter settings.
More specific, the avg_lum setting is the most important for me. Sometimes I need avg_lum=20, sometimes avg_lum=120. The other settings could remain the same.
Would it be possible to analise the luma of a specific scene, store this into a variable, and then correct avg_lum according to this variable? For the entire scene, not frame-by-frame, because then I could create flickering, right?
Fred.
videoFred
11th May 2005, 12:06
OK,
Time to show you an example:
http://users.telenet.be/ho-slotcars/testmap/videoFred_steam3_divX.avi
This 1976 Super-8 scene was original captured frame-by-frame with my modified projector. No hotspot, no flickering with this system. Then, I stabilised it with Fizicks depan plugin. Then, I converted framerate 15/25 using Fizicks script, again with the depan plugin. Watch the borders, you see how depan works. Then, I used Paviko's HDR filter to bring up more details and to improve colors. At home, I have more spectacular examples of the HDR filter, but this one gives you already a good idea.
Please remember 8mm filmframes are in fact just tiny 6x4mm pictures! Regular 8mm film was the 'mother' of all home filmsystems. Then, in 1965, Kodak launched Super-8 and Fuji Single-8 (the best).
Fred.
videoFred: the below script will calculate the average Luma for a clip and output it to a file. You can use this value as a reference for the setting (load it using conditionalread maybe)
sourcefile="c:\src"
s=AVISource(sourcefile+".avi").converttoyv12()
global fc=Framecount(s)-1
global avgl=0
s.frameevaluate("avgl=avgl+AverageLuma()")
last.writefileif(sourcefile + ".txt","current_frame==fc","avgl/(fc+1)")
videoFred
11th May 2005, 13:15
Originally posted by tsp
videoFred: the below script will calculate the average Luma for a clip and output it to a file. You can use this value as a reference for the setting (load it using conditionalread maybe)
Thank you... But I don't have expierence with scripts like this. Is this some kind of autodetection of AVI-files at line 2? Or do I have to specify my AVI file, like in common scripts? If so, where?
Fred.:confused:
no it you will have to specify it at line one just without the .avi extension.
The part sourcefile+".avi" just means take the variable sourcefile (in this case c:\src) and add .avi to the end. (so "c:\src"+".avi" = "c:\src.avi"
it's mainly done like this so the textfile that contains the average luma has the same name as the avifile (sourcefile + ".txt" = "c:\src" + ".txt" = "c:\src.txt")
videoFred
11th May 2005, 13:50
Originally posted by tsp
no it you will have to specify it at line one just without the .avi extension.
I understand now, Yes it works fine! But to have the average luma in the textfile, I must let the entire clip run in VDmod. How can we automize this?
Also, now I know the average luma of the clip,I must have a value to compare with.. Maybe 255? I mean, if I have a very dark clip with an average luma of 54, then 255-54= 201 then this is the avg_lum compensation for the HDR filter, right?
EDIT: it appears to me the average value of TSP's script IS the ideal avg_lum value for the HDR filter.. I tested it with several clips, but I am not 100% sure..must do more tests.
Fred.
Originally posted by videoFred
I understand now, Yes it works fine! But to have the average luma in the textfile, I must let the entire clip run in VDmod. How can we automize this?
Also, now I know the average luma of the clip,I must have a value to compare with.. Maybe 255? I mean, if I have a very dark clip with an average luma of 54, then 255-54= 201 then this is the avg_lum compensation for the HDR filter, right?
EDIT: it appears to me the average value of TSP's script IS the ideal avg_lum value for the HDR filter.. I tested it with several clips, but I am not 100% sure..must do more tests.
Fred.
you can do it in 2 passes with these two avs script:
pass1.avs
sourcefile="c:\src"
s=AVISource(sourcefile+".avi").converttoyv12().assumefps(200)
global fc=Framecount(s)-1
global avgl=0
s.frameevaluate("avgl=avgl+AverageLuma()")
last.writefileif(sourcefile + "_avgluma.avs","current_frame==fc",""" "AvgLuma=" ""","Round(avgl/(fc+1))")
pass2.avs
sourcefile="c:\src"
s=AVISource(sourcefile+".avi").converttorgb32()
import(sourcefile+"_avgluma.avs")
s.HDRAGC(avg_lum=AvgLuma)
finaly create a virtualdub script with extension .vcf
with this content
VirtualDub.Open("pass1.avs",0,0);
VirtualDub.Preview();
VirtualDub.Close();
VirtualDub.Open("pass2.avs",0,0);
//#VirtualDub.SetCompression() you will have to figure out the options for SetCompression
VirtualDub.SaveAVI("final.avi");
VirtualDub.Close();
start virtualdubmod chose run script... from the file menu and select the above script. That's it.
If you want to encode more files just change the avs filename to pass1_1 pass1_2 etc and repeat the virtualdub script. I don't know much about the virtualdub script language so please ask another
Backwoods
11th May 2005, 23:50
Originally posted by videoFred
Hello Backwoods again!
Thank you for your suggestions, but I must make myself more clear.
Ha, well that is what started this whole mess.
Originally posted by videoFred
Please remember 8mm filmframes are in fact just tiny 6x4mm pictures! Regular 8mm film was the 'mother' of all home filmsystems. Then, in 1965, Kodak launched Super-8 and Fuji Single-8 (the best).
I'm well aware, we talked through PM before and I do plenty of transfers myself.
Let us know how tsp's method works out for you. Sounds like it should be what you're looking for.
videoFred
12th May 2005, 15:49
Backwoods, it works fine! You must try it, too!
@TSP:thanks:
------------
It works even better, if I use the avgluma parameter to set the sigma of the HDRAGC filter also, and if I increase the avgluma with factor 1.2.
Loadplugin("HDRAGC.dll")
sourcefile="d:\analyse\11"
import(sourcefile+"_avgluma.avs")
s=AVISource(sourcefile+".avi").converttorgb32().bicubicresize(500,380)
luma2=round(avgluma*1.2)
sigm=(1.2+(avgluma/100))
clip1=s.HDRAGC(avg_lum=Luma2,min_gain=5,max_gain=15,sigma=sigm,max_sat=1,circle=3)
clip2=converttoYUY2(s)
clip3=converttoYUY2(clip1)
clip4=colorYUV(clip3,autowhite=true)
stackhorizontal(clip2,clip4)
Yes, I know color is too blue on this example, but it has been recoded several times etc.
http://users.telenet.be/ho-slotcars/testmap/02_besken.jpg
paviko
12th May 2005, 21:52
@Fizick
But do you take into acount the temporal variations?
Some time ago i made Deflicker plugin for brigthness and contrast temporal stabilizing.
What do you think about it? May be some combination is possible?
This plugin alone doesn't cause brightness flickering. There is one parameter avg_window that is using temporal averaging, but it's not meant to remove flickering that is in video from start. When it's set to 1 (as default, so no averaging) it can possibly even slightly reduce flickering if it's present.
Your Deflicker plugin is working very well. Hmm, probably it not difficult to include your code, so combination is possible :)
@videoFred
Aaaahhh! I would like to run this filter on several hundred files in batch, without the need to do settings for each individual file!
Am I dreaming? Would this be possible?
If the content of the clips differs a lot (I mean if it's captured with diffrent devices) then probably it's not possible. By automatic is set only gain and it's based on avg_lum parameter. For my camcorder I've got only one setting for every light situation.
But we can try, post examples when you need to change a lot parameters (before and after processing, so I can know what you would like to achive).
Sometimes I need avg_lum=20, sometimes avg_lum=120. The other settings could remain the same. By lowering avg_lum you influence gain calculation and force to not change bright areas, maybe better would be using coef_gain parameter (lower it instead lowering avg_lum)
Would it be possible to analise the luma of a specific scene, store this into a variable, and then correct avg_lum according to this variable?
Instead doing it by hand (these analises) it would be better to implement it to the plugin. Examples please ;), so maybe some pattern can be discovered.
Maybe 255? I mean, if I have a very dark clip with an average luma of 54, then 255-54= 201 then this is the avg_lum compensation for the HDR filter, right?
Default value for avg_lum is 128. It has been choosen because when you look for clips taken in prefect light condition the average luminance is around 128. HDRAGC is trying to increase average brightness of the clip to match avg_lum parameter. Corectness to these parameter should be mostly small in the range of 100-150. These are my observation. But maybe your device is completely different.
Regards
videoFred
13th May 2005, 07:01
Originally posted by paviko
By lowering avg_lum you influence gain calculation and force to not change bright areas, maybe better would be using coef_gain parameter (lower it instead lowering avg_lum)
Yes, I try this at home and report later.
Instead doing it by hand (these analises) it would be better to implement it to the plugin. Examples please ;), so maybe some pattern can be discovered.
Ah! You give me something to do ,this weekend :p
Monday is a free day, here in Belgium.
I come back here with lots of examples next Tuesday, OK?
But maybe your device is completely different.
Yes it is. It's a machine vision cam. 1024x768 pixels. All settings are done with the software, the iris of the lens must be set manual.
Every parameter can be set: gain, hue, sat, shutter speed etc.. independent from each other.
Here is the camera:
http://www.1394imaging.com/products/cameras/dfk31f03/?sid=08a3357210529170192ad0ec56307c87
Thank you for the follow up, and I report Tuesday, OK?
Fred.
paviko
13th May 2005, 08:49
@ videoFred
Ah! You give me something to do ,this weekend
Monday is a free day, here in Belgium.
I come back here with lots of examples next Tuesday, OK?
Please don't hurry. Do it only if you are bored, there is a lot of other more important things to do in free time ;)
And only a few (3-4) specific examples would be great, so please don't overwork.
Here is the camera:
http://www.1394imaging.com/products...92ad0ec56307c87
It's really interesting.
Regards
videoFred
17th May 2005, 07:31
Originally posted by paviko
@ videoFred
Please don't hurry. Do it only if you are bored, there is a lot of other more important things to do in free time ;)
And only a few (3-4) specific examples would be great, so please don't overwork.Regards
Hi Paviko again!
Don't worry, I like to work with video in my free time.
:D Here are the results of the Belgian jury :D
First, some fine results:
General settings where: max_sat=1, avg_lum=100, coef_gain= 0.50/1.50, sigma=2, min_gain=2.5, max_gain=15.
http://users.telenet.be/ho-slotcars/testmap/autogain_01.jpg
http://users.telenet.be/ho-slotcars/testmap/autogain_02.jpg
http://users.telenet.be/ho-slotcars/testmap/autogain_03.jpg
http://users.telenet.be/ho-slotcars/testmap/autogain_04.jpg
But on human face, it goes wrong, sometimes.
It removes too much shadows:
http://users.telenet.be/ho-slotcars/testmap/autogain_05.jpg
Reducing coef_gain does not help, then I have no effect at all.
Setting avg_lum very low (20) is the solution for this.
http://users.telenet.be/ho-slotcars/testmap/autogain_06.jpg
General results are very promising, but the picture looks a little artificial, as if is was painted. I think we must take a better look at the shadow parts of the picture. Good shadows are making a picture realistic, right?
I have this idea: next time, I overlay the result clip with the original, then maybe I can get the shadows back. I could tweak brightness etc. of the original, and make the overlay very transparant, of cource. Just enough to have some shadows back.
Fred.
communist
18th May 2005, 11:18
Great plugin - big "Thank you" from here :)
The only thing needed is speed - though I could live with the current speed aswell because the magic this plugin does on my footage is worth the time :D
paviko
18th May 2005, 21:57
@videoFred
Great. Thank you for examples.
Now I see your captures are quite specific. The image covers whole birghtness range (0-255), it's daylight and large portion of dark areas need contrast to be increased.
Changing coef_gain didn't help because you've set min_gain to 2.5.
I'll try to explain how it works. Let's assume shadow on face has brigthness value of 50, and good lit part of face has about 180. When avg_lum is set to 128 then, simplifing, every darker part of picture than 128 is magnified to the avg_lum value. HDR AGC pluging calculates maximum possible gain for pixel, you can change this calculation by min_gain (so calculated value won't be less than it), max_gain, coef_gain. If pluging calculates that paticular scene needs 2.0 gain then if you set coef_gain to e.g 0.6 it will take 0.6 * 2.0 (=1.2), but now if you also set min_gain to 2.5 then it will be 2.5 at last.
So shadow of face (50) is magnified to 128. Because gain is 2.5, then it will be 125 (50 * 2.5). Bright part of face is left with 180 brightness. So contrast on face is lost (there is only diffrence between 125 and 180, previously 50 - 180) :(
When you set avg_lum to 20, shadow of face is above it (50), so it remains untouched. Again simplifing (not all is totally true ;) ) only part of pictures darker than 20 will be gained.
It looks like for your capture device it's best to play with low avg_lum values.
Here is example of what it looks like with default parameters and max_sat = 1.0 and coef_gain = 0.7. Face is to bright, but constrast is not so much lost. Better result is with lower avg_lum I think ;)
http://img102.echo.cx/img102/5879/trainhdr3ec.jpg
It looks like the second algorithm I'm working on should process these kind of pictures much better from scratch (without tuning). But now it's still on paper, lets wait for a true results :)
@communist
The only thing needed is speed Maybe with later releases some speed can be achived. It looks like it won't be from SSE or YV12 as I previously thought. But also it could be a bit slower but with better quality. We will see how it progress :D
Regards
Backwoods
18th May 2005, 23:09
Originally posted by paviko
But also it could be a bit slower but with better quality.
I can live with that.
videoFred
19th May 2005, 06:58
Originally posted by paviko
It looks like the second algorithm I'm working on should process these kind of pictures much better from scratch (without tuning). But now it's still on paper, lets wait for a true results :)
@communist
Maybe with later releases some speed can be achived. It looks like it won't be from SSE or YV12 as I previously thought. But also it could be a bit slower but with better quality. We will see how it progress :D
Aha! This is very good news! Thank you also for the explanation.
Fred.:cool:
paviko
21st May 2005, 12:00
By going through new algorithm I was enlighted how to improve speed of current algorithm :) So here it is new version which is 4 times faster and reduces significantly halo artifacts of previous version.
Version 0.1.5 alpha - 21.05.2005:
- improvments - 4 times faster with reduced halo artifacts (if you want old behaviour use parameter mode = 0)
HDR AGC 0.1.5 alpha version (http://www.klient.neostrada.pl/HDRAGC0.1.5.zip)
PS. I will update images on the first post later. I'm too lazy now ;)
Regards
communist
21st May 2005, 13:14
Originally posted by paviko
- improvments - 4 times faster with reduced halo artifacts
No kiddin - quick test results: Old version ran at steady 1fps while this one runs at exactly 4fps (sometimes 6) (when just doing 'Run video analysis pass' in VDub 1.6.5). Great plugin just got better :)
Will do some more testing later.
paviko
21st May 2005, 18:05
By the way. I've forgotten to write that now it's somehow possible to overcome those nasty plastic look (e.g. the sample videoFred posted - boy at the train). By increasing "circle" parameter more local contrast can be preserved. It will slow down, but with e.g circle 32 it's still much faster than previous implementation with circle 7.
Here is result with new implementation and changing circle from 7 to 32 (with VideoFred parameters - avg_lum = 100, sigma = 2.0, ...):
http://img268.echo.cx/img268/5387/trainhdr0hs.jpg
I recommend as default value for circle to be 12. I'll change it in next version, because now default is still 7.
Regards
rfmmars
22nd May 2005, 19:25
Originally posted by videoFred
Please remember 8mm filmframes are in fact just tiny 6x4mm pictures! Regular 8mm film was the 'mother' of all home filmsystems. Then, in 1965, Kodak launched Super-8 and Fuji Single-8 (the best).
On paper this is true but rarely happens in the real world. I have only two Super8mm films that have surpassed the best Kodak 8mm, and I have had many great 8mm films to telecine.
Here's some of the reasons.
Nothing can comparaed to the satruated Kodachrome 8mm ASA 10. Tight grain and super sharpness.
When Super 8 came into the market other things were happening at the same time. Kadachrome II asa 40 was interduced with, more grain with less color satuation, with the isea that you didn't need to use the floodlights anymore, big mistake that couldn't be reversed in the furture.
Also "auto Focus" & "Auto Exposure" were interduced which work just like their modern day counterparts, they don't! Vertial jitter was a major problem with Super 8 which hasn't been solved yet today. This only happen in the poorest cameras of the 8mm era.
So in the day of 8mm, starting in the late 30's, film was very expensive and the photographer took care in setting the focus and exposure as compared to the point and shoot of the Super 8 days.
And last was the explosion of non-kodak processing, some good, and many not. Adding then poor storage, to the equation, I stll love 8mm.
richard
photorecall.net
videoFred
23rd May 2005, 07:31
Originally posted by paviko
By going through new algorithm I was enlighted how to improve speed of current algorithm :) So here it is new version which is 4 times faster and reduces significantly halo artifacts of previous version.Regards
Now you have worked in the weekend!:devil:
Thank you for the new version!
I test it at home and report later.
Fred.
videoFred
23rd May 2005, 07:36
Originally posted by rfmmars
On paper this is true but rarely happens in the real world. I have only two Super8mm films that have surpassed the best Kodak 8mm, and I have had many great 8mm films to telecine.
You are absolutely right. But when I mentioned "the best" I was refering to Single-8, not to Super-8.
I bet, now in digital age, many people can not imagine how "cool" these old -clockwork!- regular-8 cameras where!:cool:
Fred.
rfmmars
23rd May 2005, 18:19
I have never seen single 8, was that Fuji's format?
richard
videoFred
24th May 2005, 06:55
@Paviko:
The new version works fine! A lot faster, and almost no halo effect anymore. Plastic look is also much better. With overlay() of the original, with opacity=0.3, the result is perfect! Can I offer you a Belgian beer?:D
http://users.telenet.be/ho-slotcars/testmap/Fuji.jpg
@Richard:
The above picture is Fuji Single-8 (1975). Single-8 was very popular here in Europe.
Quality was very good, as you see. Fuji used the same principles as Regular-8.
The pressure plate was on the camera, not on the cartridge.
But the film format was the same as Super-8.
@Anyone who can help me :D
Please take a look at the picture above: the left picture is the not manipulated original, the right one is sharpened with MSharpen() and unfilter(). Now, if you enlarge the picture, you see artifacts, caused by sharpening, not by the HDR filter.
Does anyone have a suggestion for a good sharpening filter for this kind of pictures?
Thank you in advance,
Fred.
Didée
24th May 2005, 08:49
videoFred:
I'd say LimitedSharpen() is at least worth a try :) - Also, have you tried sharpening >before< HDRAGC? The result should be somewhat different - either better or worse ...
Looking closely, you can see that the sharpening has not introduced too much new artefacts, but mainly did amplify existing artefacts. So, you definetly should use some denoising in the process: sharpening without any denoising is a bad idea most times. Or not a good one at least.
Another possibility to try:
- apply a lowpass filter with sharp transition band, to erase high(est) frequencies only
- sharpen the lowpassed source
- re-apply the difference source/lowpass'd source
The latter is ~somewhat~ similar to MSharpen. However doing all steps manually, you've much more freedom to play around with all possible settings.
videoFred
24th May 2005, 10:07
Originally posted by Didée
videoFred:
I'd say LimitedSharpen() is at least worth a try :) - Also, have you tried sharpening >before< HDRAGC? The result should be somewhat different - either better or worse ...
This must be telepathy.... I'm testing limitedSharpen() right now!:p
It looks very promising on my old machine, here. I must test this more at home, on my better machine. There I can work in full resolution.
Yes, I have done tests before and after HDRAGC, after is better.
And yes, I do use denoising: MVdenoise(). But this is film, there is always some filmgrain. I can remove all the grain with MVdenoise(), but than it looks to artificial.
Fred.
communist
30th June 2005, 12:01
Hi, has there been any new developement on this filter? I've been using it a lot lately with mg262's CompareVersions (http://forum.doom9.org/showthread.php?p=679687#post679687) function (with added subs) to play with the parameters.
However the problem is if I set debug=1 I cant see the whole value - would it be too difficult to allow for alignment (like in Subtitle()) or place it somewhere else (preferably in the upper right corner)? :)
Raziel6969
30th June 2005, 21:41
Hello, :)
There is a filter like HDRAGC for photo? i have many pictures taken with my digital camera at night that have low-poor ilumination (exposition) because of the poor flash. I've already used gamma, levels, etc; but i still feel unlucky with this approach, i've read than working with layers help a bit, but your filter looks better than anything.
Bye :P
videoFred
1st July 2005, 06:51
OK, I did *LOTS* of tests with HDRAGC. I have the best results if I overlay the original clip with an amount of the HDRAGC clip, using a mask to cover the bright parts.
Here is my simple script:
Loadplugin("HDRAGC.dll")
clip1=AVISource("Myclip.avi")
masker=greyscale(invert(clip1)).tweak(bright=-90,cont=1.2)
converttoRGB(clip1)
clip2=HDRAGC(max_sat=1,avg_lum=100,sigma=1.5,coef_gain=2.5,circle=9,max_gain=14,min_gain=0.5)
clip3=overlay(clip1,clip2,opacity=0.3,mask=masker)
clip3
With opacity you can play with the amount of the overlay.
Fred.
videoFred
1st July 2005, 06:57
Hello, :)
There is a filter like HDRAGC for photo?
Bye :P
You can import photos in Avisynth, then apply the filter, then export the photos again.
You need ImageReader / ImageWriter for this.
Fred.
E-Male
1st July 2005, 10:59
(shameless plug)
or immaavs, which will read many more formats
(end of shameless plug)
paviko
1st July 2005, 18:57
has there been any new developement on this filter? I've implemented algorithm I mentioned a few post above. It provides really good (I would say great) image, but unfortunatelly is not quite usable for moving pictures (video). When some areas of different luminance are moving this algorithm can cause the sudden change of the gain, so some parts are flickering (it's interesting that not a whole frame is flickering but only some objects!). I was deeply investigating the cause and concluded it can't be defeated because picture is create from derivatieves that are not integrable :(
So I'm back to current algorithm with some thoughts how to improve it :) Shortly: adaptive radius size and use of logarithm tone mapping. But first I need to end my thesis at University and then can take on this plugin :(
However the problem is if I set debug=1 I cant see the whole value - would it be too difficult to allow for alignment (like in Subtitle()) or place it somewhere else (preferably in the upper right corner)? It shouldn't be a problem - debug parameter is using Subtitle code :)
@Raziel6969
There is a filter like HDRAGC for photo? I've recently discover that Photoshop (CS, CS2, Elements 3.0) with "Shadow/Highlights..." filters provides similar functionality. It differs a bit - you need to do first some leveling if image is dark and then "Shadow/Highlights...".
I'm thinking of doing plugin for photo editor. Especially the one that is using algorithm described above. For which program do you think should I do it? Photoshop or some free one ?
@videoFred
Here is my simple script...
Thanks a lot.
Regards
DeepDVD
3rd July 2005, 19:51
There is a filter like HDRAGC for photo? i have many pictures taken with my digital camera at night that have low-poor ilumination (exposition) because of the poor flash.
There is a similar function in Photoshop since CS (v8). Also AutoFX AutoEye 2 and Shadow Illuminator of Intrigue Technologies can make this.
The Blueness-error is well known in these older filters btw.
It would be cool if there will be a function which could control the best lightening of shadows in each frame. The backlight-problem is well known in older homemade videos.
Raziel6969
5th July 2005, 21:38
Hello again,
Thanks for the quick answers.
Paviko, i will very happy :) with a photo plugin!
I like GIMP a lot (freeware), i love to have your plugin there.
Photoshop is very used, and Paintshop Pro can use his plugins (i think).
Thanks DeepDVD & videoFred (when you have too many photos is unpractical) for the tips!
Bye
mkanel
17th July 2005, 14:19
I've implemented algorithm I mentioned a few post above. It provides really good (I would say great) image, but unfortunatelly is not quite usable for moving pictures (video). ...
So I'm back to current algorithm with some thoughts how to improve it :)
Paviko,
When time permits would you consider posting the filter with the above mentioned algorithm? I sometimes use Avisynth to make a quick collage with various frames from a video, the collage is a single frame so the flickering shouldn't be a problem.
Thanks for the filter.
Mike.
paviko
24th July 2005, 11:45
OK mkanel.
I'll post it, but I'll have to change code so setting parameters will be allowed. I was doing it quickly and everything was hardcoded. Currently I spending all free time doing my thesis, I can be late with it :(
Strange I didn't get any notifiaction that there was a reply to this thread ??
As far as working on this filter is concerned . Before I had to break developing it for some time I've implemented everything I wanted. I think it's working well :) The halos have been defeated as much as possible (almost not existent), plastic look minimized also. I need to clean the code and some MMX, SSE optimization would be also recommended, because now it runs with about 2fps.
Regards
mkanel
25th July 2005, 04:03
Thanks Paviko,
Please take your time, I'm in no hurry, and good luck with your thesis.
Mike.
Video Dude
26th July 2005, 04:47
Wow. This filter is amazing.
:thanks:
vcmohan
4th September 2005, 04:41
I have a photo which looks washed out. Can HDRAGC help out? I tried it with some parameters but looks I could not get proper values.
http://img17.imageshack.us/img17/3833/ariel9tp.jpg (http://imageshack.us)
Thanks
paviko
4th September 2005, 11:56
You can't do anything with already blown highlights. The information is lost forever :( Is it only picture or video?
Regards
vcmohan
5th September 2005, 03:12
Its a picture. I tried windowed histogram equalization and levels. It becomes slightly better but other artifacts come out strongly.
paviko
8th September 2005, 17:01
If you want to darken some parts of picture you can try invert() function before HDRAGC and then set min_gain to value grater than 1.0 (eg. 1.5) and finally invert() again to revert back.
Highlights will be processed in the next release of HDRAGC, but of course blown areas can't be recover.
Regards
paviko
23rd October 2005, 17:56
HELLO!
So long, that I've almost forgotten what was planned to do ;) For now new version with lots of new changes.
Version 0.2.0 - download at my homepage (http://strony.aster.pl/paviko/)
Version 0.2.0 - alpha - 23.10.2005:
- completely new lighting routin (sigma parameter not needed)
- new mode (mode = 2) in which radius is adaptively choosen, this removes artifacts as much as I was able to do. Slow, but faster and much, much better than mode = 0
- mode = 1 is again 2 times faster (and will be faster later, still no MMX, SSE optimization)
- new parameter - protect - for value = 1 it can help in some situation with blowing highlights (default on)
- new parameters - contrast, limit - for denoising/sharpening, almost for free - no slow down (experimental)
Notes:
It looks like the algorithm behind HDRAGC can be used for denosing or sharpening. I've written only 5 lines to implement them. Sharpening/denoising are almost not using additional CPU time - so are for free! :D For now it's a bit experimental, because I need to read more about denoising/sharpening to improve it.
New mode (mode = 2) that remove artifacts and is final algorithm. Now I'll look closer to optimization (MMX, SSE) and YUV colour formats. Mode 2 on my Althon 2GHz is 2fps, mode 1 is now faster and goes 8fps.
Comparision (old version / new version)
http://img10.echo.cx/img10/7668/backlighthdr7cu.th.jpg (http://img10.echo.cx/my.php?image=backlighthdr7cu.jpg)http://img441.imageshack.us/img441/3795/backlightnew6wf.th.jpg (http://img441.imageshack.us/my.php?image=backlightnew6wf.jpg)
http://img122.echo.cx/img122/2853/shadowhdr9rq.th.jpg (http://img122.echo.cx/my.php?image=shadowhdr9rq.jpg)http://img441.imageshack.us/img441/4325/shadownew2ww.th.jpg (http://img441.imageshack.us/my.php?image=shadownew2ww.jpg)
Sharpening with contrast set quite high to 1.6 (before / after)
http://img441.imageshack.us/img441/3795/backlightnew6wf.th.jpg (http://img441.imageshack.us/my.php?image=backlightnew6wf.jpg)http://img441.imageshack.us/img441/1866/backlightsharp7gk.th.jpg (http://img441.imageshack.us/my.php?image=backlightsharp7gk.jpg)
http://img441.imageshack.us/img441/4325/shadownew2ww.th.jpg (http://img441.imageshack.us/my.php?image=shadownew2ww.jpg)http://img441.imageshack.us/img441/1627/shadowsharp8yr.th.jpg (http://img441.imageshack.us/my.php?image=shadowsharp8yr.jpg)
Denoising with contrast set to 0.5 (before / after)
http://img441.imageshack.us/img441/3347/lowlightnew4lv.th.jpg (http://img441.imageshack.us/my.php?image=lowlightnew4lv.jpg)http://img441.imageshack.us/img441/6881/lowlightdenoise3px.th.jpg (http://img441.imageshack.us/my.php?image=lowlightdenoise3px.jpg)
videoFred
24th October 2005, 15:02
Thank you for further developing this interesting filter, Paviko! :thanks:
I try this new version as soon as possible and report back here.
But I can already say the HDR filter gives better results if you use FFT before.
HDR is a very fine filter indeed..
Sometimes it does miracles.
But I prefer to mix it with the original. :D
Fred.
paviko
26th October 2005, 18:45
Thank you videoFred. With new version you can try also how it works without blending. With new lighting routing blending should be similar to decreasing half coef_gain (if gain is auto set) or min_gain/max_gain (if set manually). Using FFT probably help, because by gaining you are increasing noise (grain), which comes visible in dark areas of picture.
New version 0.2.1 that corrects bug with denoising/sharpening when gain reachs maximum.
Version changes:
Version 0.2.1 - alpha - 25.10.2005:
- fixed sharpening/denoising (they were turned off when gain was not applied to image)
- fixed protect mode
Version 0.2.1 - download at my homepage (http://strony.aster.pl/paviko/)
Pookie
27th October 2005, 02:56
I was hoping we'd see an update to this great filter. Thanks :)
paviko
13th May 2006, 16:35
HDR AGC Version 1.8
What's new:
- huge jump in version, huge jump in quality ;)
- improved old algorithm from version 0.2.1 (mode = 0), new algorithm (mode = 1) that even for high gains give natural picture
- added support for YV12 and YUY2, removed RGB32
- 3 times faster (but still without MMX, SSE, SSE2 optimizations)
- 10 times less memory usage
- better handling of saturation
- new parameters for subtle color correction (shift_u, shift_v)
Lots of parameters have changed, check help file.
Small comparision for forced very high gain - min_gain = 5.0
(original picture / old version / new version with corrector = 0.8)
http://img463.imageshack.us/img463/8356/flowernormal03dg.th.jpg (http://img463.imageshack.us/my.php?image=flowernormal03dg.jpg)http://img463.imageshack.us/img463/1623/flowerold00wo.th.jpg (http://img463.imageshack.us/my.php?image=flowerold00wo.jpg)http://img98.imageshack.us/img98/4241/flowernew01vs.th.jpg (http://img98.imageshack.us/my.php?image=flowernew01vs.jpg)
Regards
Boulder
13th May 2006, 16:39
Thanks, the YUY2/YV12 support is very much appreciated :)
Boulder
13th May 2006, 16:45
Hmm, VirtualDubMod vanishes immediately when trying to load a script with HDRAGC in it.
paviko
13th May 2006, 18:12
What parameters have you used? What's the clip size and color space?
[Edit]
I can't find any parameter that can casue crash. Maybe you've downloaded "old" 1.8 version, because I've been uploading it rigth just when writing post.
Regards
Boulder
13th May 2006, 20:08
Nope, even the "new" 1.8 crashes.
This script doesn't work:
AVISource("e:\temp\captures\dv_1.avi")
Trim(6875,7655).FadeIn(25).FadeOut(5)
AssumeBFF()
TDeint(mode=1)
HDRAGC()
AssumeBFF()
SeparateFields()
SelectEvery(4,1,2)
Weave()
This does work:
AVISource("e:\temp\captures\dv_1.avi")
Trim(6875,7655).FadeOut(5)
AssumeBFF()
TDeint(mode=1)
HDRAGC()
AssumeBFF()
SeparateFields()
SelectEvery(4,1,2)
Weave()
That is, if I use FadeIn in the script, VDubMod vanishes. Weird..
The clip is 720x576 ffdshow HuffYUV, YV12 colorspace. I'm using tsp's latest Avisynth build (based on 2.5.6) if that's of any help.
paviko
13th May 2006, 21:45
Thank you Boulder for detailed explanation. The crash is because of completely black frame. I've encouter it previously and fixed, but it looks like it has come back ;) Will fix it in a few minutes.
Thanks
paviko
13th May 2006, 22:05
Version 1.8.1
Fixed crash for black frame thanks to Boulder.
Regards
Is possible to select the range where HDRAGC to be applied? Example: from between frame 1000 and 2000.
enjoy,
Mtz
ApplyRange (http://www.avisynth.org/Animate)
Thanks but if I'm using this:
#HDRAGC(coef_gain=0,coef_sat=1)
ApplyRange(3570,3575,"HDRAGC")
if have different results than this:
HDRAGC(coef_gain=0,coef_sat=1)
#ApplyRange(3570,3575,"HDRAGC")
And the desired result of HDRAGC is in the second example, but I don't have the range.
enjoy,
Mtz
Alain2
14th May 2006, 02:04
why not
trim(0,1000)++trim(1001,2000).HDRAGC(coef_gain=0,coef_sat=1)++trim(2001,0)
?
Backwoods
14th May 2006, 02:47
Looking forward to testing this.
videoFred
16th May 2006, 08:21
Paviko,
Great improvement!:thanks:
First test: (1976 Super-8 film frame)
http://users.telenet.be/ho-slotcars/HDR/HDR_Doom_001.jpg
Conclusion: The new HDRAGC is very very good:) :) :)
Another test: (1968 Super-8 film frame)
http://users.telenet.be/ho-slotcars/HDR/HDR_Doom_005.jpg
Histogram HDRAGC frame:
http://users.telenet.be/ho-slotcars/HDR/HDR_Doom_006.jpg
Histogram HDRAGC + ColorYUV(autogain=true):
http://users.telenet.be/ho-slotcars/HDR/HDR_Doom_007.jpg
Histogram
HDRAGC + ColorYUV(autogain=true)+ LimitedSharpenFaster:
http://users.telenet.be/ho-slotcars/HDR/HDR_Doom_008.jpg
It looks like LimitedSharpenFaster is fixing the histogram!!:cool:
Can someone explain this? :confused:
Fred.
paviko
16th May 2006, 22:19
@Mtz
Is possible to select the range where HDRAGC to be applied? Example: from between frame 1000 and 2000.
Internaly HDRAGC doesn't have range feature. To remove flickering HDRAGC by default is averaging parameters for 1 seconds. So to get the same result with range as with whole clip you need to start applying it 1 second earlier. Try maybe also Dissolve internal avisynth filter.
@videoFred
Thanks. You can try also using "shift" parameters because as I see your input video doesn't have true blacks. Maybe then, there is no need to use ColorYUV(autogain=true). Thats really interesting with LimitedSharpenFaster. Maybe denoising used internally spread pixel values nicly.
Regards
videoFred
18th May 2006, 06:49
You can try also using "shift" parameters because as I see your input video doesn't have true blacks. Maybe then, there is no need to use ColorYUV(autogain=true).
This works fine!
The result is much better then colorYUV(autogain=true).
Is there a way I could measure one frame, then apply the needed value to the shift parameter for the entire clip? With other words, is it possible to automize the shift parameter?
No one else using this amazing filter?
Fred.
rfmmars
18th May 2006, 07:13
This works fine!
The result is much better then colorYUV(autogain=true).
Is there a way I could measure one frame, then apply the needed value to the shift parameter for the entire clip? With other words, is it possible to automize the shift parameter?
No one else using this amazing filter?
Fred.
Yes I am using it now, this is the first version that has worked good for me in 8mm and Super 8mm film restoration. Before, there were too many artifact to be useful.
I needed a replacement for MSU's Smart Brightness which is great but due to errors, it can't be used in jobs or "VCFs"
It looks like HDRagc is better than Smartbrightness but I haven't played around very much with it, just an adjustment from standard setup.
Richard
photorecall.net
videoFred
18th May 2006, 07:36
Yes I am using it now, this is the first version that has worked good for me in 8mm and Super 8mm film restoration. Before, there were too many artifact to be useful.
Hello Richard,
I agree with this.
Paviko did a fine job, this time.
PS: any news from your new cam?;)
Fred.
rfmmars
18th May 2006, 19:24
Hello Richard,
I agree with this.
Paviko did a fine job, this time.
PS: any news from your new cam?;)
Fred.
Yes, the Sony DXC 755 has worked out great. I can do a two wheel color analog correction on the fly, plus black level clamp. I have added multiable Tiffen Ultra contrast and low contrast filters to the lens to help with highlight blowouts.
http://www.tiffen.com/contrast_filters.htm
Richard
photorecall.net
paviko
22nd May 2006, 18:30
Is there a way I could measure one frame, then apply the needed value to the shift parameter for the entire clip? With other words, is it possible to automize the shift parameter?
Good point videoFred. I don't know why I've missed that ;) Should be in next version.
Regards
Hi all,
I'm accustomed to old avg_lum parameter (i.e. if video has big dark zones and big bright ones also, it helps to reduce avg_lum). The new version have not this parameter then facing bad videos is more difficult for me. I'm not suggesting to recover avg_lum. I think actual filter is far away better than old.
Come into bussines. In any extreme case (dark video, high contrast) I can't gain enough luma even rising "coef_gains" and "corrector" parameters. It helps a lot insert a previous filter tweak(cont=0.8). Playing with cont value, i can reach desired luma and saturation values. I haven't tested with normal videos but preprocessing with tweak can be an interesting way to enhance filter's results.
videoFred
23rd May 2006, 07:17
Good point videoFred. I don't know why I've missed that ;) Should be in next version.
Regards
So it is possible?
That would be perfect!
No way we could get some kind of auto white balance, too?
Here's another example of how HDR AGC brings back detail in the dark parts:
max_gain=25, coef_gain=2.5, coef_sat=0.8, shift=10
http://users.telenet.be/ho-slotcars/HDR/HDR_Doom_009.jpg
Fred.
anton_foy
23rd May 2006, 12:34
that I thought was impossible...must try this at once! It should be applied before adding curves and other filters right?
videoFred
23rd May 2006, 12:49
Yes, before any other filter.
But if there is no information in the dark parts then it will not work of cource.
It depends on the exposure settings of the original.
It works fine with photos, too.
Fred.
paviko
23rd May 2006, 21:45
@AVIL
I'm accustomed to old avg_lum parameter. In any extreme case (dark video, high contrast) I can't gain enough luma even rising "coef_gains" and "corrector" parameters...
Thanks AVIL for pointing some things out.
I've removed avg_lum parameter to decrease the confusion with so many of them. Basicaly avg_lum was similar to coef_gain. When you set it to 64 instead of 128 it was almost the same as coef_gain set to 2.0. Almost because there were some cases when it wasn't and looks like you have some clips when it was helpfull. It can be added back, because it won't change algorithm, etc.
In new version I've lowered the value proposed by auto system. When in old version plugin proposed gain at 2.5, new version propose only 1.75.
Unfortunatelly the most importnat change is how coef_gain works. And your points shows that the change is wrong. Will revert it back to previous behaviour in next version.
E.g. for bright scene:
Old version propose 1.2 gain, you set coef_gain to 3.0 and as result get 3.6 gain.
New version propose 1.1 gain, you set coef_gain to 3.0 and as result get 1.3 !!!
This is my mistake, that coef_gain is not balanced anymore. To get the same gain you have to set it to 36!
Also keep in mind that max_gain is set by default to 3.0. You can try also min_gain.
Thanks
hanfrunz
29th May 2006, 20:59
@paviko
where can i find the source code? I will maybe add a GUI to your filter, if it's not to difficult to put it in the existing code.
hanfrunz
Boulder
31st May 2006, 09:22
paviko,
would it be possible to add a feature in which you can choose one frame where to take the characteristics from and use those as a base for adjusting all the other frames.
The reason why I ask this is that I've got one video where in two scenes the brightness goes up-down-up-down slowly when the video proceeds. If you need a sample clip, just let me know.
G_M_C
31st May 2006, 16:20
Paviko,
Would it be possible to put the RGB32 support back in (and keeping the YUY/YV12 offcourse).
I ask this because i've found that your filter isn't only very helpfull on video ... It is on pictures/photo's too. And the RGB32 is more usefull in the picture-buissness.
If possible it would make your filter even more versatile than when it's only usable for video (from my point of view anyways ;) )
Joel Cairo
2nd June 2006, 07:56
paviko,
would it be possible to add a feature in which you can choose one frame where to take the characteristics from and use those as a base for adjusting all the other frames.
The reason why I ask this is that I've got one video where in two scenes the brightness goes up-down-up-down slowly when the video proceeds. If you need a sample clip, just let me know.
I'd very much like this too, but I'm curious as to how it would be implemented... would you take a histogram of the "template frame" and try to adjust the target frame's histogram to match it? Or does the histogram (or whatever measure is used) change from scene to scene, thereby making the idea a lot more difficult to code?
Just curious...
-Kevin
G_M_C
2nd June 2006, 23:38
Paviko,
Would it be possible to put the RGB32 support back in (and keeping the YUY/YV12 offcourse).
I ask this because i've found that your filter isn't only very helpfull on video ... It is on pictures/photo's too. And the RGB32 is more usefull in the picture-buissness.
If possible it would make your filter even more versatile than when it's only usable for video (from my point of view anyways ;) )
Hate to quote myself, but i still hope for an anwer.
To illustrate the ussefullness of the HDRAGC plugin in pictures i give you the following example:
ORIGINAL
http://tweakers.net/ext/f/5765d796bb5601143683a783bed40ea9/full.png
WITH HDRAGC
http://tweakers.net/ext/f/140c166972f77a2a9598c7817efeb4c2/full.png
(images resized for forum-purposes)
I think this demonstrates the use for HDRAGC on photo's nicely. Thyerefore i hope that you'll be able to put back the RGB32 (besides the other formats) :)
paviko
3rd June 2006, 11:28
Hello,
Sorry for no response so long. I was quite busy.
where can i find the source code? I will maybe add a GUI to your filter, if it's not to difficult to put it in the existing code.
The source code was available with old versions. Then I removed it pior cleaning (there was so much mess, it was a shame). Now I thinking of using this algorithm in commercial application. It's just palnning so for now I'm not providing the source code. Even if this algorithm will be used commercially, the free vesion will be available for Avisynth as usual.
would it be possible to add a feature in which you can choose one frame where to take the characteristics from and use those as a base for adjusting all the other frames.
OK. I'll add this in next or just after next version ;)
I'd very much like this too, but I'm curious as to how it would be implemented... would you take a histogram of the "template frame" and try to adjust the target frame's histogram to match it? Or does the histogram (or whatever measure is used) change from scene to scene, thereby making the idea a lot more difficult to code?I'm not doing any histogram operations with current version, exept for counting how much gain apply in auto mode. So there is no problem to take all parameters from one frame and use them for other frames.
Would it be possible to put the RGB32 support back in (and keeping the YUY/YV12 offcourse).
I ask this because i've found that your filter isn't only very helpfull on video ... It is on pictures/photo's too. And the RGB32 is more usefull in the picture-buissness.I've removed RGB32 support because I was too lazy to implement own conversion :) . I've seen that since Avisynth 2.6 there will be support for YV24, which will allow to process RGB32/RGB24 image without lossing any chroma information. Does anyone know when Avisynth 2.6 will be ready? If it's not planned soon then I can add RGB32 support back.
Regards
foxyshadis
3rd June 2006, 13:41
YV24 is still 8-bit though, you need 16-bit 4:4:4 YUV to ensure that chroma in light and dark areas doesn't get quantized away into ugly banding. But 2.6 should support that, even if it's not implemented initially or compatible with many plugins.
(Pretty sure it's going to be a very long time before 2.6 though. I'm considering a custom backport involving recompiling all my favorite plugins against an avisynth 2.5 with extra colorspaces to get yv24 support. Plugins will all have to be recompiled anyway.)
G_M_C
4th June 2006, 09:45
Seems that putting the RGB back is "the easiest" way to go, since the next version of AVS is still a bit away (and it would require adding more colorspaces anyway ;) )
Mug Funky
5th June 2006, 04:49
i'm all for RGB48... :cool:
HDR is far more effective when you have more bits to play with. especially if you shoot 12-bit RAW pics on your camera and decode them to 16-bit RGB. photoshop just doesn't cut it sometimes, and lacks a feature like HDRAGC (though i'm only talking photoshop 7, not CS2 or anything).
avsutil + imagereader/writer make avisynth quite useful for processing photos :)
paviko
10th June 2006, 22:05
especially if you shoot 12-bit RAW pics on your camera and decode them to 16-bit RGB Yes, that would be great to take "RAW" 12-bit, before some gamma like curves are applied. So maybe some research :)
This weekend I'm at work :( I've decided to bring new version that was already a week ago. I wanted to add the features of taking parameters from one frame and RGB32 and then release, but it will be delayed.
Version 1.8.5
- added auto shifting (black_clip parameter)
- avg_lum parameter is back
- new mode (mode = 2), which is using float precision for some calculations (best quality, now mode = 2 as default)
- fixed behaviour of coef_gain (for coef_gain > 1.0 it works as in previous versions)
- tweaked corrector (by default it's not a bit lower, so if you were using previously x, now try x + 0.1)
Regards
videoFred
12th June 2006, 08:02
Paviko,
Black_clip=0.5 gives me this: a flat histogram.
http://users.telenet.be/ho-slotcars/HDR/HDR_Doom_015.jpg
Changing it to 1.0 or 0.1 or whatever does not make it any better.
Shift=15 gives me this:
http://users.telenet.be/ho-slotcars/HDR/HDR_Doom_014.jpg
As you see, this is much better.
????? Fred.
paviko
12th June 2006, 09:41
VideoFred try shift = 0 and black_clip = 0.01 or evene lower - this value should be low. When you set debug = 1, you will see what the shift is applied.
Regards
videoFred
12th June 2006, 10:15
Thank you for very fast reply;)
black_clip= 0.01 and shift=0 gives me shift 20 with debug=1
But I need shift= 12 or 15
I even tried black_clip= 0.0005, I still get shift 20.
The only way to get shift=15 is this:
black_clip= 0.0, shift=15
Fred.
dosdan
12th June 2006, 10:34
I thought HDRAGC would improve the situation when a videocam's auto-exposure got fooled. I know it can't bring things back when they are lost through over-exposure but in this example it looks like it makes things worse. Situation: a person walks closely across in front of a camera and causes the scene to be over-exposed. Look at the african boy's face, the hair of the pacific islander woman moving in front and the brightness of the red car during the crossover.
50KB JPGs:
Before (http://www.users.on.net/~dosdan/Before.jpg)
During (http://www.users.on.net/~dosdan/During.jpg)
After (http://www.users.on.net/~dosdan/After.jpg)
It seems to me that the After shot has even more brightness than the original over-exposed image.
The shots were taken using the defaults in HDRAGC. I could not find a suitable parameter to tame this behaviour. Is HDRAGC suitable for this situation, and if so, what settings should I use?
A link to a 4.5MB Huffyuv-compressed 21-frame clip of the original (360x360) is available here: HDRAGC_test_clip_huffyuv.avi (http://www.users.on.net/~dosdan/HDRAGC_test_clip_huffyuv.avi)
Pookie
13th June 2006, 08:25
dosdan - I think your original clip looks fine. Don't worry about it.
NathanX
15th June 2006, 13:26
Hi paviko,
Thanks for your pretty nice filter! I tried it on a pretty old 8mm movie from my father in law (the film is from the 1970s) which had some pretty dark scenes. The details are much more visible now, even in dark scenes and I only used standard settings!
Only thing is, that it is pretty slow, but as far as I have seen, MMX and SSE2 optimization is planned, so I am really looking forward to an speed optimized version!
Have a great time
Nathan
paviko
28th June 2006, 11:27
@videoFred
I even tried black_clip= 0.0005, I still get shift 20.
This means you don't like true blacks ;) black_clip is moving histogram to true black. Maybe try increasing gain (min_gain, coef_gain, max_gain) when black_clip is 0.0005.
Dosdan, HDRAGC is brightening dark parts without touching higlights, even if the rest of the picture is overexposed. If you'd like to darken your picture try:
clip.invert()
clip.hdragc()
clip.invert()
Maybe later I'll add also some auto enhacements to highlights.
NathanX.
MMX, SSE, SSE2 optimizations are wating for my free time ;)
Regards
NathanX
28th June 2006, 11:29
Paviko,
thanks for info, so hopefully you have some free time soon :D
johnmeyer
9th July 2006, 02:09
Your documentation erroneously refers to the "black_shift" parameter instead of "black_clip."
WorBry
8th August 2006, 20:20
Paviko, or any willing "HDRAGCologist"
I've had a good deal of success with HDRAGC brightening uniformly low lit scenes and off-setting color tints due to fluorescent light, but I'm struggling with backlit subjects.
Here's a classic 'hotel veranda' scene before and after my best attempt i.e.
HDRAGC(min_gain=2.0, coef_gain=2.0, max_sat=10, corrector=0.8, reducer=0.3)
Before
http://rapidshare.de/files/28674406/Veranda_Source_10_frames.avi.html
After
http://rapidshare.de/files/28674759/Veranda_HDRAGC_10_frames.avi.html
Any suggestions for improvement in ''bringing up'' the foreground whilst avoiding gamma haze?
Thanks,
The source is a 10 frame clip from a home DV, deinterlaced to 50fps, denoised, and archived as FFDShow-HuffYuv(YV12) i.e.
Decoder: Cedocida forced YV12 output (MPEG2 interlaced YV12 sampling)
Script:
avisource("C:\DV.avi")
Tweak(coring=true)
AssumeBFF()
mvbob()
LanczosResize(720,544)
hqdn3d(3)
RemoveGrain(mode=2)
paviko
9th August 2006, 09:15
I'll try tweaking after coming back home from work ;) At first sight it looks like the shift parameter could help.
Regards
WorBry
9th August 2006, 11:50
Thanks Paviko,
I'm thinking that a bit of post-sharpening might help improve the definition also, something like:
LimitedSharpenFaster(Smode=4,strength=20,overshoot=1)
Incidentally, do you recommend applying HDRAGC before or after denoising, or does it not matter? I'm currently doing it after because my archived source footage is already deinterlaced and denoised.
When I have time, I also intend to re-encode my archived DVD clips (from the original DV archives). In this case I normally just apply a mild degrain to the separated fields and re-weave, i.e.
avisource("C:/DV.avi")
Tweak(coring=true)
SeparateFields()
odd=SelectOdd.RemoveGrain(mode=2)
evn=SelectEven.RemoveGrain(mode=2)
Interleave(evn,odd)
Weave()
DoubleWeave.SelectEven()
Again (in theory at least), is HDRAGC best applied before or after field separation, or does it not matter?
Thanks alot
paviko
9th August 2006, 18:22
My suggestions are:
- black_clip = 0.1 - haze look is decreased, but also picture is a bit darker, then
- min_gain = 4.0, max_gain = 4.0 (to brighten it up back to the level before black clip)
- coef_sat = 2.0 - setting max_sat to 10.0 is not changing anything, if gain is below 10 and coef_sat is not used
- shift_u = -10 - because of a bit more saturation a blue cast appears, so lets warm picture a bit more with this parameter
So the whole line:
HDRAGC(max_gain = 4.0, min_gain = 4.0, black_clip = 0.1, coef_sat=2.0, shift_u = -10, corrector=0.8, reducer=0.3)
I hope you'll like it.
is HDRAGC best applied before or after field separation, or does it not matter?
HDRAGC should not be applied for interlaced frame, so if frame is interlaced then separate fields first or use deinterlacer.
Incidentally, do you recommend applying HDRAGC before or after denoising, or does it not matter? I'm currently doing it after because my archived source footage is already deinterlaced and denoised.
It depends how much you are brightening up clips and which denoiser are you using. It's best to experiment. For me, if gaining with HDRAGC is low then denoising after helps retain details. If gaing is high then denoising before HDRAGC help much better in decreasing the noise.
Regards
WorBry
9th August 2006, 18:44
Excellent. Yes, that's exactly what I was looking. It constantly amazes me how much definition still exists in these shadowy images.
Thanks alot for taking the trouble and for your advice about the positioning of the filter. I'll experiment some more with that.
Much appreciated.
Joel Cairo
16th August 2006, 23:57
paviko,
would it be possible to add a feature in which you can choose one frame where to take the characteristics from and use those as a base for adjusting all the other frames.
The reason why I ask this is that I've got one video where in two scenes the brightness goes up-down-up-down slowly when the video proceeds. If you need a sample clip, just let me know.
Paviko:
I just wanted to bump this thread to see if there were any plans to add this feature to a new version of HDR AGC... for my work, I think it would be **very** useful.
Thanks for considering it!
-Kevin
steptoe
26th August 2006, 18:55
I've noticed that running the filter as default does have good results on B+W films, but those that are pretty bright in places tend to be over brightened
Any suggestions to what I can try to bring up the darker parts but reduce the brighter parts or even better leaving the brighter parts alone
johnmeyer
28th August 2006, 04:03
-- Edited to add the "corrector" setting, which eliminates the "blowing out" of highlights on some scenes.
Thanks first to the author and also to VideoFred. I'm using my 16mm 24fps film-to-video transfer device (which I've described in other threads) to transfer another 31 cans of film. HDRAGC is doing a MUCH better job of adjusting the gamma than what I was able to do in Vegas, a program that actually gives you pretty good control over levels, gamma, curves, and color. I'm still going to touch up levels in Vegas, and I'm going to do all the color timing (correction) there, but HDRAGC gives me a HUGE headstart.
Thank you!!
And, to the previous poster, here are the rather simple settings I use:HDRAGC(coef_gain=1.5,coef_sat=0.8,min_gain=1.5,avg_window=1,corrector=.7)I experimented with all sorts of advanced settings, but found this worked well. I still have to sometimes (although not usually) adjust the black and white points manually in my editing application, but this is easy. The key thing is that the murky shadows are beautifully brought up to exactly the right level.
I am restoring both B&W and color, and these same settings seem to work equally well. On really underexposed footage, the results are a tad washed out, but that is easy to fix in Vegas.
BTW, when doing the film transfer, I use a Sony FX1 (currently capturing SD, rather HDV). I use "spotlight" mode, and then use the PPV menus to adjust the auto exposure downward in order to eliminate any zebra patterns. I set zebra to 100 (not 100+). This results in a slightly underexposed image, but one that has all the highlights intact. I have adjusted bulb brightness so that I use the ND1 filter for normally exposed film. For underexposed film, I remove this filter.
Here is a before/after on a B&W image:
http://forum.doom9.org/attachment.php?attachmentid=6102&stc=1&d=1156733769
paviko
2nd September 2006, 21:26
Hello.
@Joel Cairo
I just wanted to bump this thread to see if there were any plans to add this feature to a new version of HDR AGC...
Sorry, it's ages since I've promised to add this feature. I'll try to do this as soon as possible.
@steptoe
Any suggestions to what I can try to bring up the darker parts but reduce the brighter parts or even better leaving the brighter parts alone
As johnmeyer has posted try using "corrector" parameter. The lower the value from 1.0 then less bright part are changed or even are not touched.
Thank you johnmeyer.
Regards
johnmeyer
3rd September 2006, 01:07
And thank you, Paviko!
I'm in the middle of transferring over 40 reels of film, and not only has HDRAGC saved me a huge amount of time, it also does a better job bringing detail out of the shadows and in general getting the gamma "right" than almost anything I could do in Vegas, even when creating my own custom "S" curves. Very nice piece of work.
As to the corrector parameter, I'm still experimenting. The "best" value for my work is somewhere between .65 and .85. I'm currently using .75, which is a little different than what I posted.
John
videoFred
4th September 2006, 07:39
Johnmeyer,
Wonderful B/W pictures!
I see your transfer device is top quality, now!
Real film rocks:devil:
I must test this 'corrector' parameter myself.
But HDR also improves colors a lot: (recent 2005 Single-8 film frame)
http://users.pandora.be/ho-slotcars/HDR/HDR_Doom_020.jpg
Fred.
videoFred
4th September 2006, 13:38
I Tried the corrector parameter on this one:
very old 1968 Super-8 film frame
http://users.pandora.be/ho-slotcars/HDR/HDR_Doom_021.jpg
I had to capture this particular scene so dark because of the very high contrast. Otherwise the whites in the down left corner where blowing out- typical for film - higher dynamic range then digital systems can capture.
coef_gain=1.5, corrector=0.7
Man Paviko, I like your plugin :thanks: again!
Fred.
Joel Cairo
5th September 2006, 04:00
Hello.
@Joel Cairo
Sorry, it's ages since I've promised to add this feature. I'll try to do this as soon as possible.
Regards
Great, paviko...! I appreciate your efforts, and I'll look forward to that!! :D
-Kevin
paviko
9th September 2006, 15:34
Version 1.8.6
- added 'freezer' parameter - number of frame that is choosen to calculate gain parameters
As requested new parameter ('freezer') for pointing out from which frame takes all parameters.
Next on the list is RGB support.
Regards
Pookie
9th September 2006, 17:38
Thanks once again, Paviko :)
paviko
10th September 2006, 17:45
Version 1.8.7
- fixed crash when black_clip is not used :stupid: ;)
Thank you
taeuber
22nd September 2006, 16:19
Hallo Paviko,
I'm sorry to read this:
The source code was available with old versions. Then I removed it pior cleaning (there was so much mess, it was a shame). Now I thinking of using this algorithm in commercial application. It's just palnning so for now I'm not providing the source code. Even if this algorithm will be used commercially, the free vesion will be available for Avisynth as usual.
I'm only on Linux boxes so I can't use your filter.
Could you be so kind to tell me which documentation your filter is based on?
I'm interested in the »simulating the work of our eyes« algorithm and the range spreading (only luma or chroma too?).
Are there free docs on the internet?
On my Linux I use avidemux for cutting and encoding video. This program can use filters too. Maybe I find someone who tries to write a similar filter for us linux user.
Thank you very much.
Lars
Bh4i
24th September 2006, 15:41
GREAT man, especially for old movies :)
Piper
26th September 2006, 21:51
Hello,
First, thanks to paviko for writing this filter. From what I've seen on this thread it is quite powerful and the response you're getting is very encouraging!
I've been attempting to do my first 8mm capture (1958!) and I only stumbled across this thread the other day. My capture equipment is very modest, but I should be able to get something watchable out of it.
It looks as though I'm encountering a common problem with capturing overexposed scenes. The result is that the dark areas become too dark and the result is too much contrast. I'm hoping to overcome some of this with HDR_AGC. I've fiddled with it some, but so far I end up with a picture that looks comparatively washed out.
This sequence was filmed at 18fps and captured with an NTSC minidv camcorder with a shutter speed of 1/60.
Source:
http://img139.imageshack.us/img139/6197/nohgcpr0.jpg (http://imageshack.us)
With HDRAGC using: hdragc(coef_gain=1.1,max_sat=1.0,corrector=0.7,reducer=0.6)
http://img88.imageshack.us/img88/9076/withhgcgv9.jpg (http://imageshack.us)
Admittedly the resulting change here is very minor. What I'm looking for is a stronger effect without washing out the image. Would anyone have any ideas how to better approach this?
My current script looks like this:
DirectShowSource("X:\medium_blue_reel_final.avi").AssumeBFF()
ReInterpolate411()
ColorYUV(levels="PC->TV")
ConvertToYV12(interlaced=true)
DoubleWeave.SelectOdd()
AssumeTFF()
Telecide()
Decimate(5).Decimate(4)
Assumefps(18)
changefps(23.976)
DeFlicker(percent=50,scene=30)
hdragc(coef_gain=1.1,max_sat=1.0,corrector=0.7,reducer=0.6)
dull = last
sharp = dull.LimitedSharpenFaster(smode=4)
sharp = LRemoveDust_YV12(17,1)
sharp = sharp.DeGrainMedian()
Soothe(sharp, dull,80)
Thanks in advance.
rfmmars
27th September 2006, 02:05
In addition to HDRagc you need to use 'Fdump's) EQrgb 2.1 and ColorMill 2.1 to get what you want, these are VD plugins, and addition to reduce the brightness range, several "Tiffen" Ultra Low Contrast filters stacked in front of your Camcorder (F15). Use a medium green based 8.5 x 11 dull cardboard sheet projection screen to lower the blue effect and also if you print an iverted hotspot on that cardboard screen, that will help a lot.
Richard
photorecall.net
videoFred
27th September 2006, 06:35
Like Richard says, you capture too bright.
The sky around the car and the upper part of the (wonderful!)car is blown out.
No way to recover this, there is nothing to recover. Just white.
You see the peak in the histogram.
Please capture this scene again, but expose on the bright parts this time.
Like I did on my examples in this thread.
Maybe you can set your camcorder in manual modus?
Then you will have a very dark picture.
But with a lot of info hidden in the dark parts.
This is the point where HDRAGC does his magic :cool:
Fred.
krisq
27th September 2006, 10:25
OMG paviko! This plugin is working miracles on my material :D
Dzieki :thanks: ;)
Piper
27th September 2006, 16:45
@Richard & Fred: Thanks for your your replies.
Then you will have a very dark picture.
But with a lot of info hidden in the dark parts.
This is the point where HDRAGC does his magic
This point solidified it for me, thanks.
The options on my camcorder include perhaps using the backlight option which should lower the gain somewhat. Other options are "spotlight" and "surf & snow" modes.
When I captured this I used the cameras halogen setting for the white balance which I presume is the correct setting. I've attempted to keep any auto settings turned off, including focus.
@Richard: I've read that using a piece of 8 1/2" x 11" bright white printer paper is a good option, perhaps even using some aluminum foil behind it. This is what I've used for this example. Would a good camera shop have the type of projection screen you've mentioned?
I've looked up Tiffen filters, and I may be able to pick one up off of ebay. Given their price, I doubt I'll be buying several of them. I'm not sure what you meant by (F15), or which type of ultra contrast filter I'd need as there are apparently a few types. Can you please elaborate?
FredThompson
15th October 2006, 08:03
This might have some helpful information: http://www.popphoto.com/howto/3038/how-to-create-high-dynamic-range-images.html
guada 2
15th October 2006, 08:35
Many thanks FredThompson for this link.
I didn't know the plug-in Photomatix tone mapping for adobe photoshop.
Bye. ;)
Piper
15th October 2006, 16:51
Thanks again for the tips above. I've since tracked down a filter for my camcorder. It took some time but I was able to come up with a Hoya cir-polarizing filter (pitch: 0.75). Using this filter has indeed corrected the washed out scenes significantly. The issue I'm having now is tweaking hdragc effectively. I've experimented using other examples posted in this thread as guides. So far about the best I've been able to come up with is this:
Without hdragc:
http://img427.imageshack.us/img427/4888/withouthdrbb0.th.jpg (http://img427.imageshack.us/my.php?image=withouthdrbb0.jpg)
With hdragc: hdragc(max_sat=1.2,min_gain=4.0,max_gain=5.0,coef_gain=0.5,corrector=0.7,coef_sat=0.8)
http://img143.imageshack.us/img143/9097/withhdrmc1.th.jpg (http://img143.imageshack.us/my.php?image=withhdrmc1.jpg)
This image is one of the brighter frames and while it is now longer washed out, I'd like to brighten it further and reduce haze. I've tried using black_clip but even with lowest settings the blacks end up being too dark. I've also tried using tweak but I wasn't happy with the results.
Can anyone help further improve this capture? Once I think I've got all I can out of hdragc, I'll deal with denoising. In comparison to the original images I posted earlier, those were denoised using
dull = last
sharp = dull.LimitedSharpenFaster(smode=4)
sharp = LRemoveDust_YV12(17,1)
sharp = sharp.DeGrainMedian()
Soothe(sharp, dull,80)
The current images contain no denoising. The complete filter chain I'm currently using is:
# Source
AVISource("c:\tape1.avi").AssumeBFF()
ReInterpolate411()
ColorYUV(autowhite=true)
ColorYUV(levels="PC->TV")
ConvertToYV12(interlaced=true)
separatefields().DeFlicker(percent=50,scene=30).weave()
# Convert to top field first
DoubleWeave.SelectOdd()
AssumeTFF()
Telecide()
Decimate(5).Decimate(4)
Assumefps(18)
changefps(23.976)
hdragc(max_sat=1.2,min_gain=4.0,max_gain=5.0,coef_gain=0.5,corrector=0.7,coef_sat=0.8)
Thanks!
videoFred
16th October 2006, 08:18
The picture without HDR already looks fine!
I think this is not a good example for HDR AGC.
Adjusting the black point a little with virtual dub's levels filter schould be enough.
What do you want to improve?
Also, the pic without HDR....
Is this the original source or have you applied this already?:
ColorYUV(autowhite=true)
ColorYUV(levels="PC->TV")
I never use these... I use HDR after denoising but before anything else.
Fred.
Piper
16th October 2006, 14:54
@videoFred: My goal was to bring out more detail in the dark areas. There are some scenes on this reel which are shot in lower light which the camcorder is having difficulty picking up, with or without the lens filter.
Yes, both images have this applied:
ColorYUV(autowhite=true)
ColorYUV(levels="PC->TV")
I started playing with ColorYUV when I first started this project. At first I had the cameras colour balance set to halogen which gave the footage a redish tone, hence the use of autowhite. Since picking up the Hoya filter, I've found the camera produces a brighter picture if I set the colour balance to auto so autowhite can probably go if I stay with this colour balance setting. I'll take the two out and compare it with what I have.
As far as denoising is concerned, I typically denoise last, or before resizing on progressive video. Perhaps I'll try it immediately after deflicker, though I'd be surprised if it makes that much of a difference.
I've also noticed that my original (over exposed) frame looks sharper than my latest capture. It's tricky business focusing both the projector and camera just right! I may try to capture it again and frame it slightly better as well. Still, if hdragc isn't required with this footage then perhaps I'll start a new thread if I need further assistance rather than hijacking this one by going off topic.
Thanks
videoFred
16th October 2006, 15:20
Hi Piper!
I do not think there is more to see in the dark parts from the frame you showed us.
Yes! Please start a new thread.
We could discuss film transfering in this new thread and how to improve it by using Avisynth.
For those who are interested :)
Fred.
johnmeyer
24th October 2006, 19:52
Since I am transferring from film, sometimes I have a black border around the film. Is there a way to have HdrAGC ignore the black pixels around the border when it calculates min/max values?
Adub
10th December 2006, 04:19
so, how's development coming? :)
The reason I ask is because I drool over those sse2 optimizations.
paviko
16th December 2006, 15:08
Hello
Could you be so kind to tell me which documentation your filter is based on?
I'm interested in the »simulating the work of our eyes« algorithm and the range spreading (only luma or chroma too?).
Are there free docs on the internet?
First version used this algorithm:
http://www.cs.ucf.edu/~sumant/publications/SCCG2002.pdf
but it caused lots of artifact. Then I've searched some other staff. Here you can find great reference with source code and links to publications:
http://www.mpi-sb.mpg.de/~krawczyk/
I've tried some of algorithm from above link, but still could get satisfactory result for moving parts (they are good for still images).
The best one algorithm was:
http://www.cs.utah.edu/~reinhard/cdrom/tonemap.pdf
Current version of HDRAGC is using it's own algorithm. Not much was left from above mentioned links.
Is there a way to have HdrAGC ignore the black pixels around the border when it calculates min/max values?HDRAGC is already ignoring pure black parts when calculating min/max.
so, how's development coming?
The development is not progessing :( When I'm back home from work the computer is mostly turned off. I've got enough stearing at monitor at work. But I hope soon my mood will be better.
Regards
Adub
17th December 2006, 00:11
Oh, ok. Well getter better soon! ;)
Thanks for your work, man! It is really awesome!
R3Z
27th December 2006, 10:01
Does anyone have any suggestions on using this filter for the reverse ? IE i have a video thats pretty grey instead of being black and the singer is fairly well lit without needing anymore birghtness added.
Can this filter darken a clip like the MSU Smart Brightness and Contrast filter ?
Cheers !
rfmmars
27th December 2006, 14:06
Does anyone have any suggestions on using this filter for the reverse ? IE i have a video thats pretty grey instead of being black and the singer is fairly well lit without needing anymore birghtness added.
Can this filter darken a clip like the MSU Smart Brightness and Contrast filter ?
Cheers !
You can use invert before and after the HDRagc script. This is where you can't do without AVSp. Also "Fdumps" ColorMill 2.1 VD plugin may work for you.
Richard
R3Z
28th December 2006, 02:36
You can use invert before and after the HDRagc script. This is where you can't do without AVSp. Also "Fdumps" ColorMill 2.1 VD plugin may work for you.
Richard
Thanks for your suggestions :) Its appreciated !
actionman133
29th December 2006, 14:40
Not necessarily on topic, but I casually developed my own internal HDR filter, using levels and overlay... not expecting much, although it is easier to use than HDRAGC () in that it only has one input variable and if it weren't for 8 bit rounding, it'd look pretty good, I think...
Function HDR (clip Last, float gain) {
#low boosts shadows, high reduces highlights
low = ConvertToRGB ().Levels (0, gain, 255, 16, 235).ConvertBackToYUY2 ("pc.601")
lowmask = low.Levels (16, 1, 255, 255, 0, false)
high = ConvertToRGB ().Levels (0, 1/gain, 255, 16, 235).ConvertBackToYUY2 ("pc.601")
highmask = high.Levels (16, 1, 235, 0, 255, false)
# mix high and low into original clip
hdr1 = Overlay (last, high, mask = highmask, output = "YUY2")
hdr2 = Overlay (hdr1, low, mask = lowmask, output = (isRGB () ? "RGB32" : isYUY2 () ? "YUY2" : "YV12"))
return hdr2
}
At the moment, it's not optimal (it scales the masks twice), but it works well. Here's a couple samples:
Screenshots from Eternal Sunshine, Mi-3 and Miami Vice: http://actionman133.isa-geek.net:8080/preview/HDRtest.jpg
Footage from a DVCAM camera: http://actionman133.isa-geek.net:8080/preview/HDR_DV_Test.jpg
What do you reckon?
rfmmars
29th December 2006, 15:00
Thanks for giving us another tool, look good. HDRagc is hard to use unless you use AVSp with sliders for its functions, then very easy.
Richard
photorecall.net
trolltuning
30th December 2006, 19:52
I tried to use Hdrag in reverse with this and got nowhere despite trying a lot of settings. (I'm trying to get rid of the glare from the white talc on the stage). Is this just not a suitable task or did I just never find the right setting?http://members.atlantic.net/~andypo/go/britespot.JPG
or http://members.atlantic.net/~andypo/go/britespot4.avi
Only 4 frames so you need to download to view.
rfmmars
30th December 2006, 20:16
Ok using HDRagc, EQrgb 2.11, and colormill2.11.
http://aycu07.webshots.com/image/6326/2001470403868177783_th.jpg (http://allyoucanupload.webshots.com/v/2001470403868177783)
Richard
trolltuning
30th December 2006, 23:04
Wow, nice! I've tried to download the other two filters-followed about 5 threads and Googled but never ended up with a working link. Did you use the default settings for all three? (I don't even know if there are things to set with the other two until I can download them).
Also I'm curious why I got no noticble change inverting and using HDrag by itself.
Edit:Ah just found them both. I finally realized I should search for all posts by FDump.:p :thanks:
rfmmars
31st December 2006, 01:18
Wow, nice! I've tried to download the other two filters-followed about 5 threads and Googled but never ended up with a working link. Did you use the default settings for all three? (I don't even know if there are things to set with the other two until I can download them).
Also I'm curious why I got no noticble change inverting and using HDrag by itself.
Edit:Ah just found them both. I finally realized I should search for all posts by FDump.:p :thanks:
With HDRagc I have developed a rather detailed interface using AVSp
Script:
AVISource("e:\1.vdr.avi")
LoadPlugin("e:\AVS\Plugins\AGC.dll")
LoadPlugin("e:\AVS\plugins\removegrain.dll")
LoadPlugin("e:\AVS\Plugins\mt_masktools.dll")
LoadPlugin("e:\AVS\Plugins\warpsharp.dll")
Loadplugin("e:\avs\plugins\gradfun2db.dll")
loadplugin("e:\avs\plugins\DeGrainMedian.dll")
loadplugin("e:\avs\plugins\Smoothdeinterlacer.dll")
LoadPlugin("e:\avs\plugins\Convolution3d.dll")
LoadPlugin("e:\avs\plugins\FFT3DFilter.dll")
LoadPlugin("e:\avs\plugins\VagueDenoiser.dll")
LoadPlugin("e:\avs\plugins\depan.dll")
ConvertToYV12()
[Pre-Auto Gain=0]
colorYUV(autogain=true)
[/Pre-Auto Gain]
[Analyze Input Signal=0]
colorYUV(analyze=true)
[/Analyze Input Signal]
[Open White balance=0]
colorYUV(autowhite=true)
[/Open White balance]
Smoothdeinterlace()
HDRAGC(avg_lum=[<"Screen Radial (128)", 128, 2000, 746>],mode=[<"Mode (2)", 0, 2, 2>],passes=[<"Resample (4)", 1, 9, 4>],shift_u=[<"U Color Yel. Blue (0)", -100, +100, 0>], shift_v=[<"V Color Cyan Magenta (0)", -100, +100, 0>],protect=[<"Protect (2)", 0, 2, 1>],coef_gain=[<"Shadow Brightness (1)", 0.00, 0.5, 0.28>],max_gain=[<"Max Level (3)", 0, 8, 3.9>],corrector=[<"Corrector ((0)", 0.5, 1.5, 1.25>],reducer=[<"Reducer (0.5)", 0, 2, 2.0>],avg_window=[<"Frames Adverage (30)", 0, 120, 30>],black_clip=[<"Black Clip (0.0)", 0.0, 2, 1.2>],max_sat=[<"Max Satuation (9)", 0, 20, 15>],min_sat=[<"Min Satuation (1)", 0, 2, 0.7>],coef_sat=[<"Dark Color Level (1)", 0, 2, 1.0>])
Tweak([<"Hue (0)", -60, 60, 0.0>])
Converttorgb24
RGBadjust([<"Red (0)", 0.00, 2, 1.0>],[<"Green (0)", 0.00, 2, 1.0>],[<"Blue (0)", 0.00, 2, 1.0>])
#ConverttoYV12
#motion=DepanEstimate(trust=2.5, fftw=true)
#DepanInterleave(data=motion)
#YToUV(fft3dfilter(sigma=3, plane=1).UToY,\
#fft3dfilter(sigma=3, plane=2).VToY,\
#fft3dfilter(sigma=2, plane=0))
#SelectEvery(3,1)
ConvertToYV12()
gradfun2db( )
[Grain Reduction Heavy=0]
DeGrainMedian(limitY=7,limitUV=9,mode=0)
DeGrainMedian(limitY=7,limitUV=9,mode=1)
[/Grain Reduction Heavy]
[Grain Reduction Lite=0]
DeGrainMedian(limitY=2,limitUV=3,mode=1)
DeGrainMedian(limitY=2,limitUV=3,mode=1)
[/Grain Reduction Lite]
[Large Grain Reduction=0]
DeGrainMedian(limitY=40,limitUV=56,mode=0)
[/Large Grain Reduction]
Function LimitedSharpenFaster( clip clp,
\ float "ss_x", float "ss_y",
\ int "dest_x", int "dest_y",
\ int "Smode" , int "strength", int "radius",
\ int "Lmode", bool "wide", int "overshoot", int "undershoot",
\ int "soft", int "edgemode", bool "special",
\ int "exborder" )
{
ox = clp.width
oy = clp.height
Smode = default( Smode, 3 )
ss_x = (Smode==4)
\ ? default( ss_x, 1.25)
\ : default( ss_x, 1.5 )
ss_y = (Smode==4)
\ ? default( ss_y, 1.25)
\ : default( ss_y, 1.5 )
dest_x = default( dest_x, ox )
dest_y = default( dest_y, oy )
strength = (Smode==1)
\ ? default( strength, 160 )
\ : default( strength, 100 )
strength = (Smode==2&&strength>100) ? 100 : strength
radius = default( radius, 2 )
Lmode = default( Lmode, 1 )
wide = default( wide, false )
overshoot = default( overshoot, 1)
undershoot= default( undershoot, overshoot)
softdec = default( soft, 0 )
soft = softdec!=-1 ? softdec : sqrt( (((ss_x+ss_y)/2.0-1.0)*100.0) ) * 10
soft = soft>100 ? 100 : soft
edgemode = default( edgemode, 0 )
special = default( special, false )
exborder = default( exborder, 0)
#radius = round( radius*(ss_x+ss_y)/2) # If it's you, Mug Funky - feel free to activate it again
xxs=round(ox*ss_x/8)*8
yys=round(oy*ss_y/8)*8
smx=exborder==0?dest_x:round(dest_x/Exborder/4)*4
smy=exborder==0?dest_y:round(dest_y/Exborder/4)*4
clp.isYV12() ? clp : clp.converttoyv12()
ss_x != 1.0 || ss_y != 1.0 ? last.lanczosresize(xxs,yys) : last
tmp = last
edge = mt_logic( tmp.mt_edge(thY1=0,thY2=255,"8 16 8 0 0 0 -8 -16 -8 4")
\ ,tmp.mt_edge(thY1=0,thY2=255,"8 0 -8 16 0 -16 8 0 -8 4")
\ ,"max") .mt_lut("x 128 / 0.86 ^ 255 *") #.levels(0,0.86,128,0,255,false)
tmpsoft = tmp.removegrain(11,-1)
dark_limit1 = tmp.mt_inpand()
bright_limit1 = tmp.mt_expand()
dark_limit = (wide==false) ? dark_limit1 : dark_limit1 .removegrain(20,-1).mt_inpand()
bright_limit = (wide==false) ? bright_limit1 : bright_limit1.removegrain(20,-1).mt_expand()
minmaxavg = special==false
\ ? mt_average(dark_limit1, bright_limit1)
\ : mt_merge(dark_limit,bright_limit,tmp.removegrain(11,-1),Y=3,U=-128,V=-128)
Str=string(float(strength)/100.0)
normsharp = Smode==1 ? unsharpmask(strength,radius,0)
\ : Smode==2 ? sharpen(float(strength)/100.0)
\ : Smode==3 ? mt_lutxy(tmp,minmaxavg,yexpr="x x y - "+Str+" * +")
\ : mt_lutxy(tmp,tmpsoft,"x y == x x x y - abs 16 / 1 2 / ^ 16 * "+Str+
\ " * x y - 2 ^ x y - 2 ^ "+Str+" 100 * 25 / + / * x y - x y - abs / * + ?")
OS = string(overshoot)
US = string(undershoot)
mt_lutxy( bright_limit, normsharp, yexpr="y x "+OS+" + < y x y x - "+OS+" - 1 2 / ^ + "+OS+" + ?")
mt_lutxy( dark_limit, last, yexpr="y x "+US+" - > y x x y - "+US+" - 1 2 / ^ - "+US+" - ?")
Lmode==1 ? mt_clamp(normsharp, bright_limit, dark_limit, overshoot, undershoot) : last
normal = last
zero = mt_clamp(normsharp, bright_limit, dark_limit, 0,0)
Lmode==3 ? mt_merge(normal,zero,edge.mt_inflate()) : normal
edgemode==0 ? last
\ : edgemode==1 ? mt_merge(tmp,last,edge.mt_inflate().mt_inflate().removegrain(11,-1),Y=3,U=1,V=1)
\ : mt_merge(last,tmp,edge.mt_inflate().mt_inflate().removegrain(11,-1),Y=3,U=1,V=1)
AMNT = string(soft)
AMNT2 = string(100-soft)
sharpdiff=mt_makediff(tmp,last)
sharpdiff2=mt_lutxy(sharpdiff,sharpdiff.removegrain(19,-1),
\ "x 128 - abs y 128 - abs > y "+AMNT+" * x "+AMNT2+" * + 100 / x ?")
soft==0 ? last : mt_makediff(tmp,sharpdiff2)
(ss_x != 1.0 || ss_y != 1.0)
\ || (dest_x != ox || dest_y != oy) ? lanczosresize(dest_x,dest_y) : last
ex=blankclip(last,width=smx,height=smy,color=$FFFFFF).addborders(2,2,2,2).coloryuv(levels="TV->PC")
\.blur(1.3).mt_inpand().blur(1.3).bicubicresize(dest_x,dest_y,1.0,.0)
tmp = clp.lanczosresize(dest_x,dest_y)
clp.isYV12() ? ( exborder==0 ? tmp.mergeluma(last)
\ : mt_merge(tmp,last,ex,Y=3,U=1,V=1) )
\ : ( exborder==0 ? tmp.mergeluma(last.converttoyuy2())
\ : tmp.mergeluma( mt_merge(tmp.converttoyv12(),last,ex,Y=3,U=1,V=1)
\ .converttoyuy2()) )
(edgemode!= -1) ? last : edge.lanczosresize(dest_x,dest_y).greyscale
}
LimitedSharpenFaster(Smode=1, ss_x=2.0, ss_y=2.0,strength=400, overshoot=2)
[Post-Auto Gain=0]
colorYUV(autogain=true)
[/Post-Auto Gain]
[White Balance=0]
colorYUV(autowhite=true)
[/White Balance]
[Analyze Signal Output=0]
colorYUV(analyze=true)
[/Analyze Signal Output]
ConverttoYUY2()
[3D Convolution=0]
Convolution3D (0, 32, 128, 16, 64, 10, 0)
[/3D Convolution]
return last
EQrgb 2.11 has 17 sliders plus 2 posistion adjustments using RGB grouped.
I just used Colormoll this time just for gamma since that funtion in EQrgb is broken. Need to add that to the AVSp script.
Richard
paviko
21st January 2007, 13:01
Hello,
@actionman133
Nice script, thanks.
I needed hdragc funcionality for lots of image, so I was forced to write GIMP plugin :) Again, I was not satisfied with some results ;) and I've simplified whole algorithm. Almost nothing has left from real HDR technics, but I think that for normal pictures (not HDR) it gives now even better results.
HDRAGC 2.0.0 Beta for GIMP 2.x Win32
Download Hdragc 2.0.0 Beta for GIMP 2.x Win32 (http://strony.aster.pl/paviko/Hdragc-2.0.0betaGimp.zip)
- new algorithm
- highlights enhancements
Known bugs:
- preview is not working as it should
- controls are not organized (hmm... how to add checkbox in GTK+ :D)
It's recommended to use HDRAGC GIMP with good denoiser like Dcam Noise.
Plans:
Move the new algorithm to AviSynth plugin and then release source code.
Regards
Adub
21st January 2007, 21:39
Cool! I await the avisynth version.
Pookie
22nd January 2007, 08:51
Hey Paviko - Thanks for the links to those other HDR sites. I had to laugh, some were mentioning HDR video as though it was brand new technology. You've been doing it for almost 2 years! :D
taeuber
22nd April 2007, 17:20
Hi Paviko,
I really appreciate your efforts. Thanks!
I downloaded your GIMP plugin in the hope it would be written in the scheme scripting dialect for GIMP. So I just wanted to give it a try under Linux. But I had bad luck. :(
Anyway when you release the source maybe I'm able to port it to Linux if I'm allowed to.
Thanks
Lars
Isochroma
15th May 2007, 02:54
I've taken a great liking to this plugin, for video and now for still images!
Sample script:
imagesource("everything and nothing.jpg", fps=1, end=0) + converttorgb24(killaudio(blankclip(length=1, width=1083, height=720, fps=1)))
lanczos4resize(3610,2400)
converttoyuy2()
hdragc(max_gain=1.5,avg_lum=200,coef_gain=1.0,freezer=1)
converttorgb32()
lanczos4resize(1805,1200)
imagewriter("F:\Desktop\Output.bmp", 0, 0, "bmp")
1. get source image create
2. append a blank frame, so to use freezer=1 which allows hdragc to work properly.
3. upscale image to twice the size of the final size desired, to avoid chroma subsampling loss, and also make it even for yuy2 conversion
4. convert to YUY2
5. gain, specifying analysis frame as 1
6. upsample back to RGB32
7. resize to output size
8. write image
The results have been truly fantastic on still images, nothing else can compare!
Note that we put the source image into frame 0, and the black frame into 1. This is so that when the script is opened in Vdub, it immediately spits out the output image, rather than having the need to manually step to frame 1.
superuser
14th July 2007, 03:29
I had couple of question on HDRAGC params. Generally it clears the image pretty well and increases the gain, but the following observed points sort of upsets me
- color depth is lost. Looks like colors are diluted after processing with the filter.
- if I try to improve the depth of colors using saturation+black_clip with vairable values of corrector, there are artifacts in dark colors esp black and dark blue. More of halos sort of effect with those colors.
- There is blurriness in screen titles which appear in white.
For one of the source I had tweaked hdragc with following params:
HDRAGC(Edit: blnked)
I am using black_clip = 0.0 as I bump up black_clip > 0, I start seeing artefacts in violet color. Also have to keep corrector close to 0.5 and 0.4 to avoid halos with Black Color.
and later I am processing resultant of hdragc with tweak darken a bit with brightness params in negative, followed by denoiser and sharpner.
I may be doing something stupid also above, please any suggestion on how to avoid such colors artefacts with hdragc? Also what would be other suggested color corrector to be used in combination with hdragc?
Regards
rfmmars
14th July 2007, 07:17
I use HDRagc everyday without the problems you are stating.
1st Are you using the lastest version 1.87, there were artifacts in earlier version. One big thing is not to have the clip start with a black screen. I suggest apending a netual gray front end.
2nd If you haven't converted your HDRagc script to Avs-P, then your spinning your wheels.
3rd Be carefull of the U V settings, overdone can interduce artifacts.
4th There is no one setting that does it all, split the clip up into sections and test settings with A-B source.
I use Virtualdub to frameserve to Avs-P's HDRagc script and output it back to another copy of VDub.
Richard
photorecall.net
superuser
14th July 2007, 07:49
yes I am using ver 1.8.7 and sorry if it appears in any way I m criticizing or complaining about the above filter. .
And for determining appropriate settings for the source am using Avs-P else it would be very difficult. And in fact for the same purpose long back had copied lines of hdragc() from ur post (http://forum.doom9.org/showpost.php?p=923679&postcount=172)
Of the UV settings, I am using it to balance greenish and reddish component in the clip and also to darken the black component.
The intent of my post is to ask if in my settings there are visible params which sort of stands out and can produce artefacts.
rfmmars
14th July 2007, 19:47
This is my latest Avs-p HDRace script........to be used with Avs-p 1.39 or later.
AVISource("e:\1.vdr.avi")
LoadPlugin("e:\AVS\Plugins\AGC.dll")
LoadPlugin("e:\AVS\plugins\removegrain.dll")
LoadPlugin("e:\AVS\Plugins\mt_masktools.dll")
LoadPlugin("e:\AVS\Plugins\warpsharp.dll")
Loadplugin("e:\avs\plugins\gradfun2db.dll")
loadplugin("e:\avs\plugins\DeGrainMedian.dll")
loadplugin("e:\avs\plugins\Smoothdeinterlacer.dll")
LoadPlugin("e:\avs\plugins\Convolution3d.dll")
LoadPlugin("e:\avs\plugins\FFT3DFilter.dll")
LoadPlugin("e:\avs\plugins\VagueDenoiser.dll")
LoadPlugin("e:\avs\plugins\depan.dll")
LoadPlugin("e:\avs\plugins\depanEstimate.dll")
LoadPlugin("E:\AVS\Plugins\repair.dll")
LoadPlugin("E:\AVS\Plugins\masktools.dll")
LoadPlugin("e:\avs\plugins\mvtools.dll")
import("E:\avs\seesaw6.avs")
SetMemoryMax(512)
ConverttoYv12()
[<separator="DeHalo">]
function abcxyz(clip clp, int "rad", int "ss")
{
rad=([<"Radius (3)", -1.0, 20.0, 1.2>]) # radius for halo removal
ss=([<"Super Sampling (1)", -0.2, 3, 0.6>]) # radius for supersampling / ss=1.0 -> no supersampling
ox = clp.width()
oy = clp.height()
x = clp.bicubicresize(m4(ox/rad),m4(oy/rad)).bicubicresize(ox,oy,1,0)
y = yv12lutxy(clp,x,"x 8 + y < x 8 + x 24 - y > x 24 - y ? ? x y - abs * x 32 x y - abs - * + 32 /",U=2,V=2)
z1 = repair(clp,y,1)
maxbig = y.expand().bicubicresize(m4(ox*ss),m4(oy*ss))
minbig = y.inpand().bicubicresize(m4(ox*ss),m4(oy*ss))
z2 = clp.lanczosresize(m4(ox*ss),m4(oy*ss))
z2 = z2.logic(maxbig,"min",U=2,V=2).logic(minbig,"max",U=2,V=2).lanczosresize(ox,oy)
return( (ss==1.0) ? z1 : z2 )
}
abcxyz()
function m4(float x) {return( x<16?16:int(round(x/4.0)*4)) }
ConverttoYUY2()
[HQ Movie=0]
Convolution3D (preset="movieHQ")
[/HQ Movie]
[LQ Movie=0]
Convolution3D (preset="movieLQ")
[/LQ Movie]
[Bad Tape=0]
Convolution3D (0,32,128,16,64,10,0)
[/Bad Tape]
ConvertToYV12()
[Pre-Auto Gain=0]
colorYUV(autogain=true)
[/Pre-Auto Gain]
[Analyze Input Signal=0]
colorYUV(analyze=true)
[/Analyze Input Signal]
[Open White balance=0]
colorYUV(autowhite=true)
[/Open White balance]
Smoothdeinterlace()
[<separator="HDRagc">]
HDRAGC(avg_lum=[<"Screen Radial (128)", 128, 2000, 596>],mode=[<"Mode (2)", 0, 2, 2>],passes=[<"Resample (4)", 1, 9, 1>],shift_u=[<"U Color Yel. Blue (0)", -100, +100, -20>], shift_v=[<"V Color Cyan Magenta (0)", -100, +100, -1>],protect=[<"Protect (2)", 0, 2, 1>],coef_gain=[<"Shadow Brightness (1)", 0.00, 0.5, 0.33>],max_gain=[<"Max Level (3)", 0.00, 8, 5.58>],corrector=[<"Corrector ((0)", 0.5, 1.5, 0.8>],reducer=[<"Reducer (0.5)", 0, 2, 2.0>],avg_window=[<"Frames Adverage (30)", 0, 120, 30>],black_clip=[<"Black Clip (0.00)", 0.0, 2, 0.8>],max_sat=[<"Max Satuation (9)", 0.00, 4, 3.68>],min_sat=[<"Min Satuation (1)", 0.00, 2, 1.06>],coef_sat=[<"Dark Color Level (1)", 0, 2, 1.9>])
[<separator="Color Balance">]
Tweak([<"Hue (0)", -60, 60, 0.8>])
[RGB Adjust=0]
[<separator="RGB Setup">]
Converttorgb24
RGBadjust([<"Red (0)", 0.00, 2, 1.0>],[<"Green (0)", 0.00, 2, 1.0>],[<"Blue (0)", 0.00, 2, 0.95>])
ConverttoYV12
[/RGB Adjust]
motion=DepanEstimate(trust=2.5, fftw=true)
DepanInterleave(data=motion)
YToUV(fft3dfilter(sigma=3, plane=1).UToY,\
fft3dfilter(sigma=3, plane=2).VToY,\
fft3dfilter(sigma=2, plane=0))
SelectEvery(3,1)
[Lite Grain=0]
DeGrainMedian(limitY=2,limitUV=3,mode=0,interlaced=false)
DeGrainMedian(limitY=2,limitUV=3,mode=1,interlaced=false)
[/Lite Grain]
[Medium Grain=0]
DeGrainMedian(limitY=7,limitUV=9,mode=0,interlaced=false)
DeGrainMedian(limitY=7,limitUV=9,mode=1,interlaced=false)
[/Medium Grain]
[Med-Heavy Grain=0]
DeGrainMedian(limitY=40,limitUV=56,mode=0,interlaced=false)
[/Med-Heavy Grain]
[Bad Grain=0]
DeGrainMedian(limitY=20,limitUV=28,mode=0,interlaced=false)
DeGrainMedian(limitY=20,limitUV=28,mode=1,interlaced=false)
[/Bad Grain]
[<separator="Noise Reduction 1">]
[Noise Redution 1=0]
DeGrainMedian([<"Y-NOISE-1", 0, 255, 20>],[<"UV-NOISE-1", 0, 255, 28>],[<"MODE-1", 0, 5, 0>],interlaced=false)
[/Noise Redution 1]
[<separator="Noise Reduction 2">]
[Noise Reduction 2=0]
DeGrainMedian([<"Y-NOISE-2", 0, 255, 0>],[<"UV-NOISE-2", 0, 255, 40>],[<"MODE-2", 0, 5, 1>],interlaced=false)
[/Noise Reduction 2]
Function LimitedSharpenFaster( clip clp,
\ float "ss_x", float "ss_y",
\ int "dest_x", int "dest_y",
\ int "Smode" , int "strength", int "radius",
\ int "Lmode", bool "wide", int "overshoot", int "undershoot",
\ int "soft", int "edgemode", bool "special",
\ int "exborder" )
{
ox = clp.width
oy = clp.height
Smode = default( Smode, 3 )
ss_x = (Smode==4)
\ ? default( ss_x, 1.25)
\ : default( ss_x, 1.5 )
ss_y = (Smode==4)
\ ? default( ss_y, 1.25)
\ : default( ss_y, 1.5 )
dest_x = default( dest_x, ox )
dest_y = default( dest_y, oy )
strength = (Smode==1)
\ ? default( strength, 160 )
\ : default( strength, 100 )
strength = (Smode==2&&strength>100) ? 100 : strength
radius = default( radius, 2 )
Lmode = default( Lmode, 1 )
wide = default( wide, false )
overshoot = default( overshoot, 1)
undershoot= default( undershoot, overshoot)
softdec = default( soft, 0 )
soft = softdec!=-1 ? softdec : sqrt( (((ss_x+ss_y)/2.0-1.0)*100.0) ) * 10
soft = soft>100 ? 100 : soft
edgemode = default( edgemode, 0 )
special = default( special, false )
exborder = default( exborder, 0)
#radius = round( radius*(ss_x+ss_y)/2) # If it's you, Mug Funky - feel free to activate it again
xxs=round(ox*ss_x/8)*8
yys=round(oy*ss_y/8)*8
smx=exborder==0?dest_x:round(dest_x/Exborder/4)*4
smy=exborder==0?dest_y:round(dest_y/Exborder/4)*4
clp.isYV12() ? clp : clp.converttoyv12()
ss_x != 1.0 || ss_y != 1.0 ? last.lanczosresize(xxs,yys) : last
tmp = last
edge = mt_logic( tmp.mt_edge(thY1=0,thY2=255,"8 16 8 0 0 0 -8 -16 -8 4")
\ ,tmp.mt_edge(thY1=0,thY2=255,"8 0 -8 16 0 -16 8 0 -8 4")
\ ,"max") .mt_lut("x 128 / 0.86 ^ 255 *") #.levels(0,0.86,128,0,255,false)
tmpsoft = tmp.removegrain(11,-1)
dark_limit1 = tmp.mt_inpand()
bright_limit1 = tmp.mt_expand()
dark_limit = (wide==false) ? dark_limit1 : dark_limit1 .removegrain(20,-1).mt_inpand()
bright_limit = (wide==false) ? bright_limit1 : bright_limit1.removegrain(20,-1).mt_expand()
minmaxavg = special==false
\ ? mt_average(dark_limit1, bright_limit1)
\ : mt_merge(dark_limit,bright_limit,tmp.removegrain(11,-1),Y=3,U=-128,V=-128)
Str=string(float(strength)/100.0)
normsharp = Smode==1 ? unsharpmask(strength,radius,0)
\ : Smode==2 ? sharpen(float(strength)/100.0)
\ : Smode==3 ? mt_lutxy(tmp,minmaxavg,yexpr="x x y - "+Str+" * +")
\ : mt_lutxy(tmp,tmpsoft,"x y == x x x y - abs 16 / 1 2 / ^ 16 * "+Str+
\ " * x y - 2 ^ x y - 2 ^ "+Str+" 100 * 25 / + / * x y - x y - abs / * + ?")
OS = string(overshoot)
US = string(undershoot)
mt_lutxy( bright_limit, normsharp, yexpr="y x "+OS+" + < y x y x - "+OS+" - 1 2 / ^ + "+OS+" + ?")
mt_lutxy( dark_limit, last, yexpr="y x "+US+" - > y x x y - "+US+" - 1 2 / ^ - "+US+" - ?")
Lmode==1 ? mt_clamp(normsharp, bright_limit, dark_limit, overshoot, undershoot) : last
normal = last
zero = mt_clamp(normsharp, bright_limit, dark_limit, 0,0)
Lmode==3 ? mt_merge(normal,zero,edge.mt_inflate()) : normal
edgemode==0 ? last
\ : edgemode==1 ? mt_merge(tmp,last,edge.mt_inflate().mt_inflate().removegrain(11,-1),Y=3,U=1,V=1)
\ : mt_merge(last,tmp,edge.mt_inflate().mt_inflate().removegrain(11,-1),Y=3,U=1,V=1)
AMNT = string(soft)
AMNT2 = string(100-soft)
sharpdiff=mt_makediff(tmp,last)
sharpdiff2=mt_lutxy(sharpdiff,sharpdiff.removegrain(19,-1),
\ "x 128 - abs y 128 - abs > y "+AMNT+" * x "+AMNT2+" * + 100 / x ?")
soft==0 ? last : mt_makediff(tmp,sharpdiff2)
(ss_x != 1.0 || ss_y != 1.0)
\ || (dest_x != ox || dest_y != oy) ? lanczosresize(dest_x,dest_y) : last
ex=blankclip(last,width=smx,height=smy,color=$FFFFFF).addborders(2,2,2,2).coloryuv(levels="TV->PC")
\.blur(1.3).mt_inpand().blur(1.3).bicubicresize(dest_x,dest_y,1.0,.0)
tmp = clp.lanczosresize(dest_x,dest_y)
clp.isYV12() ? ( exborder==0 ? tmp.mergeluma(last)
\ : mt_merge(tmp,last,ex,Y=3,U=1,V=1) )
\ : ( exborder==0 ? tmp.mergeluma(last.converttoyuy2())
\ : tmp.mergeluma( mt_merge(tmp.converttoyv12(),last,ex,Y=3,U=1,V=1)
\ .converttoyuy2()) )
(edgemode!= -1) ? last : edge.lanczosresize(dest_x,dest_y).greyscale
}
[<separator="Sharping">]
LimitedSharpenFaster(Smode=1, ss_x=2.0, ss_y=2.0,strength=[<"Sharpness (400)", 0, 2400, 129>],overshoot=[<"OverShoot (0)", 0, 6, 0>])
[Post-Auto Gain=0]
colorYUV(autogain=true)
[/Post-Auto Gain]
[White Balance=0]
colorYUV(autowhite=true)
[/White Balance]
[Analyze Signal Output=0]
colorYUV(analyze=true)
[/Analyze Signal Output]
### Some values can not have sliders, if you move one of these values, it will crash and will not reset...AVS-p
### re-edits the lines incorrectly
#
#SetMTmode(2,2)
#[<separator="SeeSaw">]
#SeeSaw(NRlimit=[<"NR-Limit(4)",.1,10,4>],NRlimit2=[<"NR-Limit2(5)", .1, 10, 4>], Sstr=[<"Sstr(1.5)",.1,10,1.5>], #Slimit=[<"Slimit(9)",.1,20,9>], Spower=[<"Spower(9)",.1,20,9>], Szp=[<"Spz(16)",.1,30,16>], #sootheT=[<"smootheT(8)",.1,20,8>], bias=[<"Bias(40)",.1,80,40>] )
#
#New code
[<separator="SeeSaw">]
SetMTmode(2,2)
SeeSaw( NRlimit=10,NRlimit2=5, Sstr=[<"Sstr(1.5)", .1, 10, 4.2>],Slimit=9,Spower=9, Szp=[<"Spz(16)", .1, 30, 16.6>],sootheT=80, bias=[<"Bias(40)", .1, 80, 40.4>] )
[SeeSaw 2=0]
[<separator="SeeSaw 2">]
SeeSaw( NRlimit=4, NRlimit2=5, Sstr=1.5, Slimit=9, Spower=9, Szp=16, sootheT=80, bias=40)
[/SeeSaw 2]
[Invert Video=0]
INVERT()
[/Invert Video]
return last
Could you post some frames of the problem?
Richard
EuropeanMan
6th August 2007, 18:27
Can someone please tell me why some arguments are not valid with this line?
HDRAGC(B,avg_lum=1078,mode=2,passes=4,shift_u=-15, shift_v=6,protect=2,coef_gain=0.22,max_gain=4.0,corrector=0.8,reducer=1.1,avg_window=30,black_clip=0.3,min_sat=0.4, max_sat=16, coef_sat=1.0)
passes
shift_u
shift_v
protect
corrector
reducer
black_clip
these arguments are erroring out in AVSp...when I take them out, then MPC crashes while playing... :(
superuser
7th August 2007, 02:48
^ above lines work for me. use the rfmmars template for avsp.
johnmeyer
29th August 2007, 17:54
Previous posts have questioned whether the black_clip parameter works correctly. I don't think it does. Here are my settings:final=source.HDRAGC(coef_gain=3,shift_u =-20,coef_sat=1,min_gain=1.3,avg_window=1,shift=0,corrector=.75,black_clip=0.00029,protect=1,debug=0)This produces this result:
http://i177.photobucket.com/albums/w208/johnmeyer/Result_01.jpg
However, if I change black_clip from 0.00029 to 0.00028, I get this:
http://i177.photobucket.com/albums/w208/johnmeyer/Result_02.jpg
If I change to 0.00030 or to 0.00027, I don't get any noticeable change. Thus, there appears to be a step function
behavior with this paramater.
AlanHK
24th December 2007, 10:20
I've got an old space opera movie, which is rather too dark.
Just using
HDRAGC()
gives decent results for most scenes (especially interiors). However, some "outer space" scenes, with large areas of black sky, are brightened too much.
Is there a setting that would not overbrighten this kind of scene? (I guessed from the name that "black_clip" might do that but I can't understand how this parameter works.)
I was hoping for something like "if more than x% of the frame is more than y% black don't mess with it".
I also tried
ColorYUV(autogain=true)
which also worked okay on most scenes, but really messed up the black sky scenes, making them full of grey blocks.
rfmmars
24th December 2007, 15:24
Is there a setting that would not overbrighten this kind of scene? (I guessed from the name that "black_clip" might do that but I can't understand how this parameter works.)
Look at the script that I posted above, it has everything you need, tons of sliders for "HDRagc, must use "AVS-p" or you are spinning your wheels.
TIP: Never start with a clip that is all black or very bright.
Richard
photorecall.net
AlanHK
24th December 2007, 20:12
Look at the script that I posted above, it has everything you need, tons of sliders for "HDRagc, must use "AVS-p" or you are spinning your wheels.
TIP: Never start with a clip that is all black or very bright.
Thanks, I do use AVsP.
In the current version (2) it's defined as "AGC_HDRAGC", but doesn't have any sliders defined; I used yours with some changes.
(You might like to correct a few typos:
Adverage -> Average
Satuation -> Saturation.)
But I'm afraid the explanations of what they do is not clear to me, and randomly twiddling them has not got me far.
Can you advise just what "Black_clip" does?
And what do you mean by "Never start with a clip that is all black? Start what?
rfmmars
25th December 2007, 01:30
Hi, yes am Mr. "Typo" for sure.
Her's the lastest script
------------------------------------------------------------
AVISource("e:\1.vdr.avi")
#ImageSource("E:\train.bmp")
LoadPlugin("e:\AVS\Plugins\AGC.dll")
LoadPlugin("e:\AVS\plugins\removegrain.dll")
LoadPlugin("e:\AVS\Plugins\mt_masktools.dll")
LoadPlugin("e:\AVS\Plugins\warpsharp.dll")
Loadplugin("e:\avs\plugins\gradfun2db.dll")
loadplugin("e:\avs\plugins\DeGrainMedian.dll")
loadplugin("e:\avs\plugins\Smoothdeinterlacer.dll")
LoadPlugin("e:\avs\plugins\Convolution3d.dll")
LoadPlugin("e:\avs\plugins\FFT3DFilter.dll")
LoadPlugin("e:\avs\plugins\VagueDenoiser.dll")
LoadPlugin("e:\avs\plugins\depan.dll")
LoadPlugin("e:\avs\plugins\depanEstimate.dll")
LoadPlugin("E:\AVS\Plugins\repair.dll")
LoadPlugin("E:\AVS\Plugins\masktools.dll")
LoadPlugin("e:\avs\plugins\mvtools.dll")
LoadPlugin("e:\avs\plugins\autolevels.dll")
LoadPlugin("e:\avs\plugins\GrainOpt.dll")
LoadPlugin("e:\avs\plugins\MSU_FRC.dll")
import("E:\avs\seesaw6.avs")
LoadPlugin("e:\avs\plugins\DGbob.dll")
SetMemoryMax(512)
ConverttoYv12()
Autolevels(filterRadius=5,sceneChgThresh=254)
#Autolevels(filterRadius=8, sceneChgThresh=10,
ConvertToYV12()
HDRAGC(avg_lum=2000,mode=2,passes=1,shift_u=-31, shift_v=0,protect=2,coef_gain=0.5,max_gain=6.3,corrector=1.31,reducer=2.0,avg_window=16,black_clip=0.0,max_sat=1.56,min_sat=1.19,coef_sat=0.9)
Tweak(-1.692,1.1,-18.36,1.0)
Converttorgb24
RGBadjust(1.0,1.04,1.0)
ConverttoYV12
#SeeSaw( NRlimit=4, NRlimit2=5, Sstr=1.5, Slimit=9, Spower=9, Szp=16, sootheT=80, bias=40)
return last
### AvsP marked script ###
# AVISource("e:\1.vdr.avi")
# #ImageSource("E:\train.bmp")
# LoadPlugin("e:\AVS\Plugins\AGC.dll")
# LoadPlugin("e:\AVS\plugins\removegrain.dll")
# LoadPlugin("e:\AVS\Plugins\mt_masktools.dll")
# LoadPlugin("e:\AVS\Plugins\warpsharp.dll")
# Loadplugin("e:\avs\plugins\gradfun2db.dll")
# loadplugin("e:\avs\plugins\DeGrainMedian.dll")
# loadplugin("e:\avs\plugins\Smoothdeinterlacer.dll")
# LoadPlugin("e:\avs\plugins\Convolution3d.dll")
# LoadPlugin("e:\avs\plugins\FFT3DFilter.dll")
# LoadPlugin("e:\avs\plugins\VagueDenoiser.dll")
# LoadPlugin("e:\avs\plugins\depan.dll")
# LoadPlugin("e:\avs\plugins\depanEstimate.dll")
# LoadPlugin("E:\AVS\Plugins\repair.dll")
# LoadPlugin("E:\AVS\Plugins\masktools.dll")
# LoadPlugin("e:\avs\plugins\mvtools.dll")
# LoadPlugin("e:\avs\plugins\autolevels.dll")
# LoadPlugin("e:\avs\plugins\GrainOpt.dll")
# LoadPlugin("e:\avs\plugins\MSU_FRC.dll")
# import("E:\avs\seesaw6.avs")
# LoadPlugin("e:\avs\plugins\DGbob.dll")
# SetMemoryMax(512)
#
#
#
#
#
# ConvertToYV12()
#
# [MSU Slow Motion=0]
# MSU_FRC(4, "slow")
# [/MSU Slow Motion]
#
#
# [Super Motion=0]
# function MotionProtectedFPS(
# \ clip input, float FPS,
# \ int "mode", int "protection",
# \ int "iterate", int "reset", int "initialise")
# {
# mode = default(mode, warpfast)
# protection = default(protection, 80)
# iterate = default(iterate, 2)
# reset = default(reset, 50)
# initialise = default(initialise, 6)
#
# originalFPS = input.framerate()
# input
#
# mp = temporalsoften(2,4,5,2).FindMotion(iterate = iterate, reset = reset,
# \ initialise = initialise)
# p = MotionFPS(FPS,mode,Motion = mp)
# maskp = mp.SumStretchFPSMask(FPS, protection)
#
# mn = temporalsoften(2,4,5,2).FindMotion(iterate = iterate, reset = reset,
# \ initialise = initialise, from = next)
# n = MotionFPS(FPS,mode,Motion = mn, source = next)
# maskn = mn.SumStretchFPSMask(FPS, protection, source = next)
#
# maskp
# assumeFPS(originalFPS)
# CombineFPS(FPS, maskp, maskn.Invert())
# bilinearresize(width*8, height*8)
# crop(0, 0, input.width(), input.height())
# fity2uv()
#
# maskedmerge(p, n, last, u=3, v=3)
# }
# [/Super Motion]
#
#
#
# GrainOptimizer()
#
#
# [First Invert=0]
# INVERT()
# [/First Invert]
#
#
# ConverttoYv12()
#
# Smoothdeinterlace()
#
#
#
#
#
# [<separator="AutoLevels">]
#
# Autolevels(filterRadius=[<"Radius(8)", 0, 20, 5>],sceneChgThresh=[<"Threshold(10)", 0, 255, 254>])
#
#
# #Autolevels(filterRadius=8, sceneChgThresh=10,
#
#
#
#
#
# [<separator="Refocus>]
#
# function abcxyz(clip clp, int "rad", int "ss")
# {
# ss=([<"Core (1)", 0.00, 2.00, 0.64>]) # radius for supersampling / ss=1.0 -> no supersampling
# rad=([<"Refocus (3)", 0.0, 20.0, 0.9>]) # radius for halo removal
#
#
# ox = clp.width()
# oy = clp.height()
#
# x = clp.bicubicresize(m4(ox/rad),m4(oy/rad)).bicubicresize(ox,oy,1,0)
# y = yv12lutxy(clp,x,"x 8 + y < x 8 + x 24 - y > x 24 - y ? ? x y - abs * x 32 x y - abs - * + 32 /",U=2,V=2)
# z1 = repair(clp,y,1)
# maxbig = y.expand().bicubicresize(m4(ox*ss),m4(oy*ss))
# minbig = y.inpand().bicubicresize(m4(ox*ss),m4(oy*ss))
# z2 = clp.lanczosresize(m4(ox*ss),m4(oy*ss))
# z2 = z2.logic(maxbig,"min",U=2,V=2).logic(minbig,"max",U=2,V=2).lanczosresize(ox,oy)
#
# return( (ss==1.0) ? z1 : z2 )
# }
# abcxyz()
#
# function m4(float x) {return( x<16?16:int(round(x/4.0)*4)) }
#
#
#
#
# [<separator="DeHalo">]
#
# function abcxyz(clip clp, int "rad", int "ss")
# {
# rad=([<"Radius (3)", -1.0, 20.0, 0.3>]) # radius for halo removal
# ss=([<"Super Sampling (1)", -0.2, 3, 1.2>]) # radius for supersampling / ss=1.0 -> no supersampling
#
# ox = clp.width()
# oy = clp.height()
#
# x = clp.bicubicresize(m4(ox/rad),m4(oy/rad)).bicubicresize(ox,oy,1,0)
# y = yv12lutxy(clp,x,"x 8 + y < x 8 + x 24 - y > x 24 - y ? ? x y - abs * x 32 x y - abs - * + 32 /",U=2,V=2)
# z1 = repair(clp,y,1)
# maxbig = y.expand().bicubicresize(m4(ox*ss),m4(oy*ss))
# minbig = y.inpand().bicubicresize(m4(ox*ss),m4(oy*ss))
# z2 = clp.lanczosresize(m4(ox*ss),m4(oy*ss))
# z2 = z2.logic(maxbig,"min",U=2,V=2).logic(minbig,"max",U=2,V=2).lanczosresize(ox,oy)
#
# return( (ss==1.0) ? z1 : z2 )
# }
# abcxyz()
#
# function m4(float x) {return( x<16?16:int(round(x/4.0)*4)) }
#
#
#
#
#
# ConverttoYUY2()
#
# [HQ Movie=0]
# Convolution3D (preset="movieHQ")
# [/HQ Movie]
#
#
# [LQ Movie=0]
# Convolution3D (preset="movieLQ")
# [/LQ Movie]
#
#
# [Bad Tape=0]
# Convolution3D (0,32,128,16,64,10,0)
# [/Bad Tape]
#
#
#
#
# ConvertToYV12()
#
#
#
# [Pre-Auto Gain=0]
# colorYUV(autogain=true)
# [/Pre-Auto Gain]
#
#
# [Analyze Input Signal=0]
# colorYUV(analyze=true)
# [/Analyze Input Signal]
#
#
# [Open White balance=0]
# colorYUV(autowhite=true)
# [/Open White balance]
#
#
#
# [<separator="HDRagc">]
#
# HDRAGC(avg_lum=[<"Screen Radial (128)", 128, 2000, 2000>],mode=[<"Mode (2)", 0, 2, 2>],passes=[<"Resample (4)", 1, 9, 1>],shift_u=[<"U Color Yel. Blue (0)", -100, +100, -31>], shift_v=[<"V Color Cyan Magenta (0)", -100, +100, 0>],protect=[<"Protect (2)", 0, 2, 2>],coef_gain=[<"Shadow Brightness (1)", 0.00, 0.5, 0.5>],max_gain=[<"Max Level (3)", 0.00, 8, 6.3>],corrector=[<"Corrector ((0)", 0.50, 1.50, 1.31>],reducer=[<"Reducer (0.5)", 0, 2, 2.0>],avg_window=[<"Frames Adverage (30)", 0, 120, 16>],black_clip=[<"Black Clip (0.00)", 0.00, 2.00, 0.0>],max_sat=[<"Max Satuation (9)", 0.00, 4, 1.56>],min_sat=[<"Min Satuation (1)", 0.00, 2, 1.19>],coef_sat=[<"Dark Color Level (1)", 0, 2, 0.9>])
#
#
# [<separator="Color Balance">]
# Tweak([<"Hue (0)", -60.00, 60.00, -1.692>],[<"sat(2)", 0.00, 20.00, 1.1>],[<"Bright", -50.00, 50.00, -18.36>],[<"Cont", 0.00, 2.00, 1.0>])
#
# [<separator="RGB Setup">]
# [RGB Adjust=1]
# Converttorgb24
# RGBadjust([<"Red (0)", 0.00, 2, 1.0>],[<"Green (0)", 0.00, 2, 1.04>],[<"Blue (0)", 0.00, 2, 1.0>])
#
# ConverttoYV12
# [/RGB Adjust]
#
#
#
# motion=DepanEstimate(trust=2.5, fftw=true)
# DepanInterleave(data=motion)
# YToUV(fft3dfilter(sigma=3, plane=1).UToY,\
# fft3dfilter(sigma=3, plane=2).VToY,\
# fft3dfilter(sigma=2, plane=0))
# SelectEvery(3,1)
#
#
# [Lite Grain=0]
# DeGrainMedian(limitY=2,limitUV=3,mode=0,interlaced=false)
# DeGrainMedian(limitY=2,limitUV=3,mode=1,interlaced=false)
# [/Lite Grain]
#
# [Medium Grain=0]
# DeGrainMedian(limitY=7,limitUV=9,mode=0,interlaced=false)
# DeGrainMedian(limitY=7,limitUV=9,mode=1,interlaced=false)
# [/Medium Grain]
#
#
#
#
# [Med-Heavy Grain=0]
# DeGrainMedian(limitY=40,limitUV=56,mode=0,interlaced=false)
# [/Med-Heavy Grain]
#
# [Bad Grain=0]
# DeGrainMedian(limitY=20,limitUV=28,mode=0,interlaced=false)
# DeGrainMedian(limitY=20,limitUV=28,mode=1,interlaced=false)
# [/Bad Grain]
#
# [<separator="Noise Reduction 1">]
# [Noise Redution 1=0]
# DeGrainMedian([<"Y-NOISE-1", 0, 255, 20>],[<"UV-NOISE-1", 0, 255, 28>],[<"MODE-1", 0, 5, 0>],interlaced=false)
# [/Noise Redution 1]
# [<separator="Noise Reduction 2">]
# [Noise Reduction 2=0]
# DeGrainMedian([<"Y-NOISE-2", 0, 255, 0>],[<"UV-NOISE-2", 0, 255, 40>],[<"MODE-2", 0, 5, 1>],interlaced=false)
# [/Noise Reduction 2]
#
#
# Function LimitedSharpenFaster( clip clp,
# \ float "ss_x", float "ss_y",
# \ int "dest_x", int "dest_y",
# \ int "Smode" , int "strength", int "radius",
# \ int "Lmode", bool "wide", int "overshoot", int "undershoot",
# \ int "soft", int "edgemode", bool "special",
# \ int "exborder" )
# {
# ox = clp.width
# oy = clp.height
#
# Smode = default( Smode, 3 )
# ss_x = (Smode==4)
# \ ? default( ss_x, 1.25)
# \ : default( ss_x, 1.5 )
# ss_y = (Smode==4)
# \ ? default( ss_y, 1.25)
# \ : default( ss_y, 1.5 )
# dest_x = default( dest_x, ox )
# dest_y = default( dest_y, oy )
# strength = (Smode==1)
# \ ? default( strength, 160 )
# \ : default( strength, 100 )
# strength = (Smode==2&&strength>100) ? 100 : strength
# radius = default( radius, 2 )
# Lmode = default( Lmode, 1 )
# wide = default( wide, false )
# overshoot = default( overshoot, 1)
# undershoot= default( undershoot, overshoot)
# softdec = default( soft, 0 )
# soft = softdec!=-1 ? softdec : sqrt( (((ss_x+ss_y)/2.0-1.0)*100.0) ) * 10
# soft = soft>100 ? 100 : soft
# edgemode = default( edgemode, 0 )
# special = default( special, false )
# exborder = default( exborder, 0)
# #radius = round( radius*(ss_x+ss_y)/2) # If it's you, Mug Funky - feel free to activate it again
# xxs=round(ox*ss_x/8)*8
# yys=round(oy*ss_y/8)*8
# smx=exborder==0?dest_x:round(dest_x/Exborder/4)*4
# smy=exborder==0?dest_y:round(dest_y/Exborder/4)*4
#
# clp.isYV12() ? clp : clp.converttoyv12()
#
# ss_x != 1.0 || ss_y != 1.0 ? last.lanczosresize(xxs,yys) : last
# tmp = last
#
# edge = mt_logic( tmp.mt_edge(thY1=0,thY2=255,"8 16 8 0 0 0 -8 -16 -8 4")
# \ ,tmp.mt_edge(thY1=0,thY2=255,"8 0 -8 16 0 -16 8 0 -8 4")
# \ ,"max") .mt_lut("x 128 / 0.86 ^ 255 *") #.levels(0,0.86,128,0,255,false)
#
# tmpsoft = tmp.removegrain(11,-1)
# dark_limit1 = tmp.mt_inpand()
# bright_limit1 = tmp.mt_expand()
# dark_limit = (wide==false) ? dark_limit1 : dark_limit1 .removegrain(20,-1).mt_inpand()
# bright_limit = (wide==false) ? bright_limit1 : bright_limit1.removegrain(20,-1).mt_expand()
# minmaxavg = special==false
# \ ? mt_average(dark_limit1, bright_limit1)
# \ : mt_merge(dark_limit,bright_limit,tmp.removegrain(11,-1),Y=3,U=-128,V=-128)
#
# Str=string(float(strength)/100.0)
# normsharp = Smode==1 ? unsharpmask(strength,radius,0)
# \ : Smode==2 ? sharpen(float(strength)/100.0)
# \ : Smode==3 ? mt_lutxy(tmp,minmaxavg,yexpr="x x y - "+Str+" * +")
# \ : mt_lutxy(tmp,tmpsoft,"x y == x x x y - abs 16 / 1 2 / ^ 16 * "+Str+
# \ " * x y - 2 ^ x y - 2 ^ "+Str+" 100 * 25 / + / * x y - x y - abs / * + ?")
#
# OS = string(overshoot)
# US = string(undershoot)
# mt_lutxy( bright_limit, normsharp, yexpr="y x "+OS+" + < y x y x - "+OS+" - 1 2 / ^ + "+OS+" + ?")
# mt_lutxy( dark_limit, last, yexpr="y x "+US+" - > y x x y - "+US+" - 1 2 / ^ - "+US+" - ?")
#
# Lmode==1 ? mt_clamp(normsharp, bright_limit, dark_limit, overshoot, undershoot) : last
#
# normal = last
# zero = mt_clamp(normsharp, bright_limit, dark_limit, 0,0)
#
# Lmode==3 ? mt_merge(normal,zero,edge.mt_inflate()) : normal
#
# edgemode==0 ? last
# \ : edgemode==1 ? mt_merge(tmp,last,edge.mt_inflate().mt_inflate().removegrain(11,-1),Y=3,U=1,V=1)
# \ : mt_merge(last,tmp,edge.mt_inflate().mt_inflate().removegrain(11,-1),Y=3,U=1,V=1)
#
# AMNT = string(soft)
# AMNT2 = string(100-soft)
# sharpdiff=mt_makediff(tmp,last)
# sharpdiff2=mt_lutxy(sharpdiff,sharpdiff.removegrain(19,-1),
# \ "x 128 - abs y 128 - abs > y "+AMNT+" * x "+AMNT2+" * + 100 / x ?")
#
# soft==0 ? last : mt_makediff(tmp,sharpdiff2)
#
# (ss_x != 1.0 || ss_y != 1.0)
# \ || (dest_x != ox || dest_y != oy) ? lanczosresize(dest_x,dest_y) : last
#
# ex=blankclip(last,width=smx,height=smy,color=$FFFFFF).addborders(2,2,2,2).coloryuv(levels="TV->PC")
# \.blur(1.3).mt_inpand().blur(1.3).bicubicresize(dest_x,dest_y,1.0,.0)
# tmp = clp.lanczosresize(dest_x,dest_y)
#
# clp.isYV12() ? ( exborder==0 ? tmp.mergeluma(last)
# \ : mt_merge(tmp,last,ex,Y=3,U=1,V=1) )
# \ : ( exborder==0 ? tmp.mergeluma(last.converttoyuy2())
# \ : tmp.mergeluma( mt_merge(tmp.converttoyv12(),last,ex,Y=3,U=1,V=1)
# \ .converttoyuy2()) )
#
# (edgemode!= -1) ? last : edge.lanczosresize(dest_x,dest_y).greyscale
#
#
# }
#
# [<separator="Sharping">]
# LimitedSharpenFaster(Smode=1, ss_x=2.0, ss_y=2.0,strength=[<"Sharpness (400)", 0, 2400, 407>],overshoot=[<"OverShoot (0)", 0, 6, 0>])
#
#
#
# [Post-Auto Gain=0]
# colorYUV(autogain=true)
# [/Post-Auto Gain]
#
# [White Balance=0]
# colorYUV(autowhite=true)
# [/White Balance]
# [<separator="SeeSaw Boost 2">]
# [SeeSaw 2=0]
# SetMTmode(2,2)
# SeeSaw( NRlimit=10,NRlimit2=5, Sstr=[<"SstrT(1.5)", .1, 10, 8.3>],Slimit=9,Spower=9, Szp=[<"SpzT(16)", .1, 30, 23.0>],sootheT=80, bias=[<"BiasT(40)", .1, 80, 7.6>] )
# [/SeeSaw 2]
#
# #SeeSaw( NRlimit=4, NRlimit2=5, Sstr=1.5, Slimit=9, Spower=9, Szp=16, sootheT=80, bias=40)
#
#
### AvsP marked script ###
--------------------------------------------------------
Notice that the lastest HDRagc plugin is"AGC.dll
With HGRagc box checked, there are tons of sliders.
Black Clip sets the lowest black level (16) for my work.
There seems to be some interaction between AVS-p and HDRagc for proper operation and I found if you start with a video frame as the first one to be processed, then there's no problem, if its black or full white frame at the begining, it won't work..
http://img291.imageshack.us/img291/3034/hdr1hb5.th.jpg (http://img291.imageshack.us/my.php?image=hdr1hb5.jpg)
http://img153.imageshack.us/img153/4417/hdr2us2.th.jpg (http://img153.imageshack.us/my.php?image=hdr2us2.jpg)
you need to edit out almost all of the #, I don't know why AVSp saves that way
Richard
foxyshadis
26th December 2007, 20:40
As long as you open that in avsp, instead of copying it in, avsp will remove the hashes for you. It saves that way so that what it saves will be a real avisynth script, but at the same time still keep the sliders (which would cause errors in a real script).
JK1974
9th July 2008, 00:35
Hi,
I have a basic question on an idea that was postet at http://forum.doom9.org/showthread.php?t=118580.
I am also working on Super-8 telecine - currently having the luck being able to have a projector synchronised to 16,666... for recording the film at 50i (PAL).
Because my S8 movie had some scenes that were to dark and some that looked quite right at the same level of light, I also thought about working with it like with HDR photos:
1. Recording the film three times: With less light, with normal light and with bright light.
2. Combining all three videos to one HDR film.
3. Using tonemapping technique to move the color range back to the displayable area.
In the thread I mentioned above, it has finally been talked about the export of the HDR movie - which is not possible before AVISynth 2.6/3.0. But I don´t want to export the movie as HDR movie, I "just" want to "downscale" it before to the "normal" color range and export it "normally".
Is there any way to accomplish this? The only plug-in concerting HDR seems to be HDR AGC, but if I have seen right, this is "just" a "HDR/tonemapping simulation", or did I understand anything wrong? Don´t get me wrong: HDR AGC does a brilliant job, but as "real" HDR is possible in the case I described above, I would really be interested if I there is any "new" development besides HDR AGC or if there is any way to accomplish my needs with HDR AGC.
Undead Sega
11th November 2008, 05:09
Hi everyone, sorry for bringing such an old thread to the present time, but i cant help to say that i think indeed this is a brilliant filter and works wonders with footage that is incredibly dark (of course not that dark), but the last release we saw was just over 2 years ago, and impretty sure that improvements can still be made?
one i would like to ask, is that, the use of gain, which produces a noisy picture, which is can be irratable and many would consider non-professional. but i was wondering if it is possible to give a clean image (or footage with little gain in itself) a HDR treatment but not resulting of having such a noisy picture, or having gain resulting into the video?
Sagekilla
11th November 2008, 05:59
@Undead Sega: Unfortunately, most of the time you apply gain to any weak signal noise will be prevalent. Didee worked out a script before that works around this by providing gain (from HDRAGC) and temporal filtering (MVDegrain) to provide some very good results.
It is possible, and I think the script Didee posted was a bit rudimentary (he gave a framework and said you can fill in the blanks) but it should be able to do something like what you want.
Undead Sega
11th November 2008, 06:37
hmmm, i was pretty aware of that, it even goes for audio. however, i have seen some other HDR(I) work, and gain does not become prevelent in those cases. I do not want to bring out detail to be washed out afterwards.
isnt there another filter or plugin (commercial even) that can do the job?
mikeytown2
11th November 2008, 07:33
@Undead Sega
Open a new thread with some sample clips, we should be able to give you better advice. As Sagekilla stated, HDRAGC with MVDegrain is quite powerful.
Here's a script that I fine tuned for this clip
http://forum.doom9.org/showthread.php?t=139402
Undead Sega
12th November 2008, 02:57
ive checked out the link and the results somewhat doesnt look pleasing or doesnt quite satisfy me, HDR is there to make tonned-maps from information when having an image with low and high expsure put together, and quality shouldnt be an issue.
mikeytown2
12th November 2008, 03:13
Unless you shot the scene with 2 cameras very close together and in sync, how are you going to get the low and high exposures? A better option is to record raw data, like the Red One does. Like I said before, post some samples in a new thread. Otherwise this is it... there is nothing more we can do.
Aghora
23rd October 2010, 17:34
I'm getting this error
http://i53.tinypic.com/s664a1.jpg
leeperry
23rd October 2010, 19:50
very impressive! :eek:
but w/ MT() I get mismatched bands:
MT("""
HDRAGC(coef_gain=1.2)
colorYUV(levels="tv->pc")
""",4)
http://thumbnails19.imagebam.com/10352/f7cd4b103511528.jpg (http://www.imagebam.com/image/f7cd4b103511528)
any chance for built-in MT please? but the OP hasn't showed up since 2007, so I guess that'll never happen :(
and I'd rather not use SetMode() because it's async and it's bad for jitter in realtime IME.
PS: anyone knows of a MT plugin that'd more or less do the same?
fenomeno83
27th November 2010, 14:50
so; I have these 3 images.. look "T" product
I want make an analize based on color, but 3 images have different exposure..
http://img689.imageshack.us/img689/539/050820100030.jpg
http://img442.imageshack.us/img442/1715/05082010031.jpg
http://img574.imageshack.us/img574/4237/sam00002.jpg
so, there is any avisynth script to balance in automatic to have for example "T" with similar color/exposure..
HDR filter is image is already brighter, increase brightness
dansrfe
27th November 2010, 18:03
very impressive! :eek:
but w/ MT() I get mismatched bands:
MT("""
HDRAGC(coef_gain=1.2)
colorYUV(levels="tv->pc")
""",4)
http://thumbnails19.imagebam.com/10352/f7cd4b103511528.jpg (http://www.imagebam.com/image/f7cd4b103511528)
any chance for built-in MT please? but the OP hasn't showed up since 2007, so I guess that'll never happen :(
and I'd rather not use SetMode() because it's async and it's bad for jitter in realtime IME.
PS: anyone knows of a MT plugin that'd more or less do the same?
You cannot MT HDRAGC. It won't work. The best you ccan do for hdragc is setmtmode().
DVDBob
5th January 2011, 02:56
Where can i enable HGRagc box in AvsP, so i get all the sliders??
Gavino
5th January 2011, 10:06
It looks like information about HdrAgc is not built-in to AvsP. You will have to add the required information for the sliders, etc, yourself under Options->Avisynth function definition->Plugins.
WBL
9th January 2011, 13:35
Hello Paviko,
is there any chance that you port the HDRAGC filter to Sony Vegas? - If you dont know how to do this for Vegas you might contact a programmer which already did port other filters like the SmoothDeinterlacer to Vegas - his mane is Mike Crash (see: http://mikecrash.com/ )
thanks
Werner
Didée
9th January 2011, 14:07
If you klick on Paviko's username, you'll see that his last activity on this board was in March 2007. He's not been here for almost 4 years.
DoctorM
20th December 2012, 06:05
I've been tinkering with this on some video that is supposed to be moody dark, but is almost pitch black at times.
Hdr agc really fixes that but I feel like it needs some better fine control.
According to the debugger, no matter what I do, all gain starts at 1 and then the coef effects it as a multiplier. That is, all frames seem to be processed no matter how bright they are.
Max_gain is all well and good, but fairly useless (at least in this case). I've been forced to set Coef_gain to .1 which isn't ideal either but less aggressive.
What I'd like to be able to do:
According to the manual, the calculation is (1.0 + ((calculated gain) - 1.0) * coef_gain).
It would be nice to be able to adjust the base gain: (base_gain + ((calculated gain) -1.0) * coef_gain.
This way the gain can reach numbers <1. (I would have thought that number would be the min_gain, but it doesn't seem to be).
Second, it would be nice if there was a maximum threshold so if a frame is already above a certain brightness, it is not processed.
I'm finding already bright scenes getting VERY bright when they didn't need processing at all.
avg_lum doesn't make a difference because ALL frames still get a minimum gain of 1!
Actually, just being able to adjust the base gain to 0 would have the same effect. So really it's just one request after all.
My current script is using merge() between the original video and the processed video just to keep things under control.
Anyway, suggestions or tweaks to the filter would be great.
martin53
20th December 2012, 08:57
Because it seems unlikely to me that the author responds, I contribute my 'gain control' toolbox to stimulate your own experiments with merge, invert etc. Remove only one comment sign at a time.
SGradation (http://avisynth.org/mediawiki/SGradation) is a non-automatic contrast-like user function I once published in the wiki.
function AutoExpose(clip c,float "strength") {
strength= default(strength,0.7)
c
#Overlay(AutoLevels().hdr().hdr_inv(),opacity=strength)
#invert().hdr().invert()
#SGradation(0.8)
#merge(c,last.AutoLevels(midpoint=0.45),weight=0.5*strength)
#hdr()
}
function hdr(clip clp, float "gain", float "sat") {
clp
gain= default(gain, 1.0)
sat= default(sat, 1.0)
merge(clp,hdragc(coef_gain= gain, coef_sat= sat, mode=2, protect=1, reducer=0.0, shadows=true, debug=0),weight=0.5)
}
function hdr_inv(clip clp, float "gain", float "sat") {
clp
gain= default(gain, 1.0)
sat= default(sat, 1.0)
invert().hdragc(coef_gain= 1.0*gain, max_sat=3.0, min_sat=1.0, coef_sat= 0.6*sat, mode=2, protect=1, reducer=0.0,debug=0).invert()
}
DoctorM
20th December 2012, 09:18
@martin52: I appreciate your response... but I'm not sure I understand it.
Is this supposed to cause hdragc to work without a minimum gain?
And by 'remove one comment at a time' do you mean each is a different method that should be tried individually and separately?
martin53
20th December 2012, 10:29
@DoctorM,
user function AutoExpose is to be used in a clip script, the two other just encapsule hdragc for AutoExpose.
You might try the lines in AutoExpose to watch their effect one by one. But you might as well just read the hdragc settings I once found useful, use them as an alternative starting point to the one you find, or just stimulate your own phantasy with the ideas to apply hdragc on the inverted instead of the as-is clip, or leave automatic control and switch to constant contrast correction.
In my experience, automatic gain control looks good in still motion preview because you focus on the scenes that need correction. But when you watch the whole thing, you'll almost certainly find scenes that are bungled afterwards.
The intention of your post was to suggest a modification to hdragc, so maybe my response is off topic and not welcome. Only in case you don't stick to hdragc, I also suggest that you try a non automatic correction, maybe limited to a frame range with the help of ApplyRange().
I once made SGradation because the Super8 movies looked like silhouettes after capture with my digicam. It compresses the histogram towards the center from both sides. If you don't want the lights to be softened, just replace "1.0/g" in the "lt=..." line by "1.0" to remove the effect from this line.
DoctorM
20th June 2013, 20:31
Working on something else and I thought Hdragc MIGHT be useful.
In this case the dark scenes are too bright, but the lighter scenes are fine.
I'm basically looking to make the work as a mask(?) or something to darken the darkest scenes more, and do minimal change to the lighter scenes.
Is this possible or am I just thinking about this wrong?
Reel.Deel
23rd May 2014, 14:25
Since paviko's site is dead here's the archived link just in case someone is looking for it.
HDR AGC v1.8.7 info and download:
https://web.archive.org/web/20131018094707/http://strony.aster.pl/paviko/hdragc.htm
I also updated the link in the AviSynth wiki, would be great if a moderator can update the link in the first post.
Guest
23rd May 2014, 15:06
would be great if a moderator can update the link in the first post. Done. Thank you for the link.
Reel.Deel
23rd May 2014, 15:20
Thanks neuron2.
Unfortunately the archived link in the first post was copied incorrectly.
Here's the full link:
https://web.archive.org/web/20131018094707/http://strony.aster.pl/paviko/hdragc.htm (https://web.archive.org/web/20131018094707/http://strony.aster.pl/paviko/hdragc.htm)
Guest
23rd May 2014, 15:39
Fixed.
Argaricolm
21st September 2018, 15:59
Does anyone have HDRAGC source code?
StainlessS
21st September 2018, 16:10
Best I can do (HDR AGC version 0.1.2 alpha, latest dll I have is v1.8.7):-
http://www.mediafire.com/file/cgvipn95ssiiojt/hdragc_25_dll_20050521.zip/file
EDIT: Seems to be the only posted source, from post #24, No longer available from that link.
Argaricolm
24th September 2018, 16:25
I will try to rewrite it (want to make 64 bit version).
Your source will help a lot. Looks not very hard.
Thanks.
poisondeathray
22nd October 2018, 00:48
I will try to rewrite it (want to make 64 bit version).
Your source will help a lot. Looks not very hard.
Thanks.
Any progress on the 64bit version ?
(aka shameless bump :D)
Thanks
color
25th October 2018, 19:15
I just write to follow this thread. I also want to know about the 64bit version. =)
StainlessS
25th October 2018, 23:00
I just write to follow this thread. I also want to know about the 64bit version. =)
+1 on that.
ABDO
30th October 2018, 01:54
I just write to follow this thread. I also want to know about the 64bit version. =)
me too, +1 on that, or any improvment on HDRAGC, it is to disappointing that no profissional one can make an modern hdragc alternative, or make improvment
speed to it.
Argaricolm
18th November 2018, 23:02
Well my goal so far is to just rewrite it in C++ so we have source and x64.
I want to use StaxRip with it. But StaxRip is x64 now.
Already started to do it.
So far I can tell that there is an error in documentation.
Version 1.8.7 has mode = 1 by default.
As stated in docs for 1.8.6:
starting from 1.8.5 version:
- new mode (mode = 2), which is using float precision for some calculations (best quality, now mode = 2 as default)
But in code it is 1:
.text:10011944 mov eax, 1
SteveT
3rd January 2019, 21:30
I recently discovered HDRagc and have been using it on various videos from 16mm film. It's been great, but today I encountered a clip that yields a light colored halo around dark objects positioned on a bright background as shown in the attachment.
16644
I have HDRagc setup with:
HDRAGC(coef_gain=5.0, max_gain=9.0, min_gain=1.0, coef_sat=1.0, max_sat=9.0, min_sat=0.0, corrector=0.8, black_clip=0.000, avg_window=15, protect=2, shift_u=0, shift_v=0, reducer=0.0,avg_lum=128)
I typically use the corrector at 1.0. I set it to 0.8 to enhance the halo effect so it shows up more clearly in my attached picture.
I have tried various settings to get rid of the halo. I set corrector above 1.0 which reduces halo but oversaturates the white background. Turning protect on and off had no effect. Any idea why the halo appears and what to do about it?
Thanks,
Steve
metaspirit
15th February 2019, 01:13
Hey it is possible the aura is caused by 2 sharpening filters if you add a blur this could solve the problem have a try.
example
#
Lanczos4Resize(1280,720) # Lanczos4 (Sharp)
#
Blur(0.40)
#
asharp(1.25,6,-1,false)
#
Selur
25th March 2020, 12:53
@Argaricolm: any update regarding a rewrite and a 64bit version?
frencher
25th May 2020, 06:24
@Argaricolm: any update regarding a rewrite and a 64bit version?
Hello,
An update would be really great.
Do you have a dominant redness problem on your videos ?
:goodpost:
Mounir
27th May 2020, 10:20
it's better when the snow is white
https://www.hostpic.org/images/2005271449230088.jpg
StainlessS
27th May 2020, 19:00
Mournir, much better, but looks a little bit cyan-ish to me, little bit too much red removed [but my eyes are lousy].
Anyway post you mod for OP.
Mounir
27th May 2020, 20:35
i used gimp's levels filters with manual selection for the white/gray/black
Selur
1st June 2020, 07:23
Sadly the plugin gives an Access Violation when using Avisynth 3.6.
Any hope for an update of this plugin?
kedautinh12
1st June 2020, 11:40
Sadly the plugin gives an Access Violation when using Avisynth 3.6.
Any hope for an update of this plugin?
Can you use with 3.6.1 test 4??
StainlessS
1st June 2020, 14:51
I thought I'de try in GamMac, see what happens.
SHOW=False
RedMul1=1.00
RedMul2=1.06
LockChan1=1
LockChan2=LockChan1
Scale1=2
Scale2=Scale1
O = Imagesource(".\Halo effect with HDRagc.JPG")#.Crop(3,5,-6,-7)
M = Imagesource(".\2005271449230088.jpg")#.Crop(3,5,-6,-7)
G1= O.Gammac(Th=1.0/256,LockChan=LockChan1,Scale=Scale1,dc=O.Blur(0.2),redmul=REDMUL1,show=SHOW)
G2= O.Gammac(Th=1.0/256,LockChan=LockChan2,Scale=Scale2,dc=O.Blur(0.2),redmul=REDMUL2,show=SHOW)
O = O.subtitle("Original")
M = M.subtitle("Mournir")
G1= G1.subtitle("Gammac_1")
G2= G2.subtitle("Gammac_2")
T=stackHorizontal(O,M)
B=stackHorizontal(G1,G2)
StackVertical(T,B)
There is a white border thing around edge, but gamMac default is 20 pixels ignored around all borderrs, so we dont need to crop.
click to enlarge
https://i.postimg.cc/ykp8dVKV/Color-00.jpg (https://postimg.cc/ykp8dVKV)
As still a bit cyan-ish, applied a red multiplier, not as bright as Mournir, but a bit more balanced prior to maybe tweak by hand.
There seems to be some kind of halo or aura around the little girl (extending far from her - see it best in original pic).
EDIT: You could eg add args omin=5 omax=250 to gammac args to leave some tweaking lee-way [default is 0, and 255]
EDIT: Maybe back-off on the redmul a bit, maybe Gammac2 looks too red again.
manolito
3rd June 2020, 14:28
Can you use with 3.6.1 test 4??
On my Core i5 Thinkpad with Win7-64 it crashes under AVS+ 3.61 test version 4, but it runs without problems under test version 2.
manolito
3rd June 2020, 22:13
Test version 5 also does not like HDRAGC, need to revert to test version 2.
//EDIT//
The brand new 3.6.1 test version 6 handles HDRAGC with flying colors, and I also did not find any older CPP 2.5 plugins which would cause crashes.
metaspirit
2nd August 2020, 21:48
I have Hdragc working with MP_pipeline it gives a very nice fps boost this is in mode2 i don't think there would be much if any improvement if it was running a pure Hdragc x64.
i am running x64 avisynth+ with megui x64 i too still get the halo problem i am not sure what the cause is
it could be that luma is getting too much gain i wish there was a way to have a limiter built in for over 128 tv levels there is too much gain at the top but the enhanced shadows do look good
i hope this fps boost will help others.
gispos
3rd August 2020, 19:58
Well, with avisynth_64 you can only use HDRAGC with MP_Pipeline. So I've always had the fps boost.:)
minusthebear
5th August 2025, 16:19
Im surprised no one has created a 64-bit version of this plugin. It is incredible in what it can do and nothing I've seen in terms of AI tools, or otherwords comes close.
Selur
6th August 2025, 04:21
from what I see: developer gone, no source code, so creating a 64bit version would require a complete rewrite,... (even if there were source code, the whole assembler code would need a rewrite)
qyot27
8th August 2025, 05:58
from what I see: developer gone, no source code, so creating a 64bit version would require a complete rewrite,... (even if there were source code, the whole assembler code would need a rewrite)
The source for 0.1.2 alpha is available, which is what the avisynth.nl wiki and StainlessS pointed to further upthread.
The changelog details that there definitely were deeper things that got altered in between 0.1.2 (last version with source, or at least the last one with source recovered from the depths of the Internet Archive) and 1.8.7 (the final version, if you don't count the GIMP plugin that got posted).
Luckily (or not? if later versions are what people actually want) 0.1.2 alpha does have a license; it's GPLv2.
This is all it took to get it building natively on Linux:
https://github.com/qyot27/hdragc/commit/e2f5c1fe668cca36aae6cfcab69cdb0fa8cdf40b
It very much looks like:
A) The asm is only used by the antialiaser for what I assume is an info text overlay
B) The plaincode implementation of what the asm is doing appears to be directly above it, commented out
C) That asm probably isn't even necessary these days, so disabling it and letting the compiler do that work with the non-asm version is likely fine
D) Most/all of the Windows-specific parts have to do with that text stuff.
E) There were parts that seemed to rely on/overload stuff in the AviSynth source itself, which got removed, because there's no point. One function had to be renamed to avoid a conflict with C++11 std headers.
F) It seems to multithread well, and appears to tolerate aggressive compiler optimization (-O3 -march=native).
https://i.imgur.com/sKztutR.png
$ file libhdragc.so
libhdragc.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=693537f0e317497afbac07fd5151ef2ad65eea83, not stripped
$ objdump -a libhdragc.so | grep format
libhdragc.so: file format elf64-x86-64
qyot27
8th August 2025, 06:12
Here's the thing, though: I'm pretty sure that whatever newer versions of HDRAGC were doing, you can probably get similar or better results by using newer tonemapping plugins or faking HDR using frame properties and letting mpv tonemap when playing back the script. One of the last posts the dev made about the research papers used as reference for the plugin even mentions Reinhard as the best option in said literature (then mentions that HDRAGC uses something different). And while Reinhard did/does have a lot of people now that still prefer it, there are other, newer algorithms.
minusthebear
12th December 2025, 02:25
Here's the thing, though: I'm pretty sure that whatever newer versions of HDRAGC were doing, you can probably get similar or better results by using newer tonemapping plugins or faking HDR using frame properties and letting mpv tonemap when playing back the script. One of the last posts the dev made about the research papers used as reference for the plugin even mentions Reinhard as the best option in said literature (then mentions that HDRAGC uses something different). And while Reinhard did/does have a lot of people now that still prefer it, there are other, newer algorithms.
Any personal recommendations for an alternative to this plugin? In AviSynth or even in a GUI app etc.
qyot27
12th December 2025, 03:37
Plugins: avslibplacebo, avsresize, maybe DGTonemap.
If you don't care about the playback being hardware accelerated, like I said in the quote you can change the frame properties in the script by using propSet() and then open the script in mpv, which can handle the tonemapping of HDR->SDR¹, or (presumably) properly engage the monitor's/OS' HDR mode. I don't have an HDR monitor to get into the weeds on that part.
¹libplacebo is essentially mpv's video renderer in library form, so avslibplacebo should definitely be able to do this in-script.
Columbo
12th December 2025, 13:46
Also HW-accelerated DGHDRtoSDR() if nVidia graphics is available.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.