Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 20th August 2011, 11:49   #1  |  Link
bizz & buzz
Banned
 
Join Date: Jun 2008
Posts: 94
Chromatic aberration - Using Tweak() on edges only?

Hi,

While removing blue and yellow chromatic aberration with Tweak(), I noticed that it also kills color where it shouldn't - on people's clothes etc.

Because chromatic aberration is mostly on edges and not texture, will it be helpful to target Tweak() only on edges?

Or perhaps there's a different solution to the problem?
bizz & buzz is offline   Reply With Quote
Old 20th August 2011, 16:07   #2  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,340
maybe using an edge mask (masktools)?
poisondeathray is offline   Reply With Quote
Old 20th August 2011, 19:28   #3  |  Link
bizz & buzz
Banned
 
Join Date: Jun 2008
Posts: 94
This is exactly what I want to do but I have no idea where to start.
bizz & buzz is offline   Reply With Quote
Old 20th August 2011, 20:33   #4  |  Link
Nephilis
--preset WTF!
 
Join Date: Feb 2009
Posts: 86
Code:
src=last
a=src.mt_edge(mode="prewitt",0,255,0,255,u=3,v=3)
b=a.tweak(with preferred settings)
src.mt_merge(a,b,u=3,v=3)
Nephilis is offline   Reply With Quote
Old 20th August 2011, 21:54   #5  |  Link
jmac698
Registered User
 
Join Date: Jan 2006
Posts: 1,867
You could always use the plugin made just for this:
Quote:
Chromatic Aberration Correction (CA Correct)

What it does: This filter allows you to radially scale (i.e., zoom) the R, G, and B channels of a video stream with independent scale factors. This can be used to correct radial chromatic aberration.

For example, if white objects have a green inner border, then scale the green channel outward with a scale factor >1 to overlay the green channel with the other channels as best as possible. This is similar to what is offered in a number of software packages for still images.

Notes:

1. Since this is radially scaling a frame, it should be used with PROGRESSIVE video. Otherwise, strange blending of fields will occur.

2. To use with INTERLACED video, first apply your best deinterlacer, then use CaCorrect, then reinterlace if necessary.

3. You have to zoom IN on particular channels for correction. Zooming OUT is not permitted, as this would create border effects at the edges of the video.

4. Since the CA is roughly constant only at a fixed zoom position, this software won't be useful for shots where the zoom setting is changing substantially during the shot.

5. And this only does radial correction. Any non-uniform, non-radial aberration won't be able to be corrected by this software.
http://www.wrgardner.com/CaCorrect.vdf

It's for virtualdub, but you can use virtualdub filters in avisynth:
http://avisynth.org/mediawiki/FAQ_us...ualdub_plugins

and remember, for any question you can search for "chromatic aberration plugin for virtualdub or avisynth"
jmac698 is offline   Reply With Quote
Old 20th August 2011, 21:55   #6  |  Link
bizz & buzz
Banned
 
Join Date: Jun 2008
Posts: 94
Thanks Nephilis! but I'm getting strange results when using this (with Tweak's defaults):

Source:


Result:

Last edited by bizz & buzz; 20th August 2011 at 22:21.
bizz & buzz is offline   Reply With Quote
Old 20th August 2011, 21:59   #7  |  Link
jmac698
Registered User
 
Join Date: Jan 2006
Posts: 1,867
ps If you wanted to write your own script, I believe there is an effects plugin that can do radial zoom.
Try EffectLens
http://avisynth.org/vcmohan/EffectsM...any_index.html
jmac698 is offline   Reply With Quote
Old 20th August 2011, 22:21   #8  |  Link
bizz & buzz
Banned
 
Join Date: Jun 2008
Posts: 94
Thanks jmac698, but the link for VirtualDub's plugin is dead? I've searched for it but couldn't find it.
I did find FixChromaticAberration filter for Avisynth, but it throws an error - Invalid arguments to function "IsRGB" (FixChromaticAberration.avsi, line 30)
bizz & buzz is offline   Reply With Quote
Old 20th August 2011, 22:51   #9  |  Link
jmac698
Registered User
 
Join Date: Jan 2006
Posts: 1,867
Code:
c= (IsRGB(clip)) ? clip : ConvertToRGB(clip)
change to:
c=ConvertToRGB(clip)
This will just avoid the error.

Try contacting the author
http://www.dvinfo.net/forum/general-...-software.html

This is a real example of digital decay, it's a significant problem for plugins.
The plugin might also be in the filter pack at digitalfaq
http://www.digitalfaq.com/forum/vide...lters-pre.html

I can't find a list of the filters.
jmac698 is offline   Reply With Quote
Old 21st August 2011, 00:44   #10  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by bizz & buzz View Post
I did find FixChromaticAberration filter for Avisynth, but it throws an error - Invalid arguments to function "IsRGB" (FixChromaticAberration.avsi, line 30)
It's a bug in the function declaration:
Code:
function FixChromaticAberration(clip "clip", val "red", val "green", val "blue", val "x", val "y")
Remove the quotes from "clip".
These wrongly make the clip optional, preventing you from using implicit 'last' as the parameter.

As written, the function will work if you pass the input clip explicitly.
jmac698's fix does not work.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 21st August 2011, 14:31   #11  |  Link
bizz & buzz
Banned
 
Join Date: Jun 2008
Posts: 94
Thanks Gavino, it worked!
Unfortunately this filter doesn't seem to remove this particular CA...
Although I couldn't find VirtualDub's CA plugin, it seems (according to its description) to be along the lines of Avisynth's FixChromaAberration filter... which means it too won't help much in removing this CA.

Will it be possible to have a look at why I'm getting this strange result with Nephilis' code?
bizz & buzz is offline   Reply With Quote
Old 23rd August 2011, 22:33   #12  |  Link
Yellow_
Registered User
 
Join Date: Sep 2009
Posts: 378
What about a simple spill suppression on the blue channel?

http://www.yellowspace.webspace.virg...illsupblue.jpg
Yellow_ is offline   Reply With Quote
Old 25th August 2011, 12:24   #13  |  Link
bizz & buzz
Banned
 
Join Date: Jun 2008
Posts: 94
Looks good!! can this be done in Avisynth? I am not aware of any Spill Suppression filter...

Different question: Is it posible to limit Tweak from affecting areas that are larger then certain size? i.e, if there's a patch of color that was about to be changed by Tweak, and it's larger than a certain size (say a 2x8 block) - Then it will not be changed by Tweak!

Is that possible ??
bizz & buzz is offline   Reply With Quote
Old 25th August 2011, 13:38   #14  |  Link
Yellow_
Registered User
 
Join Date: Sep 2009
Posts: 378
I used the nodal open source compositor in Blender, which has various chroma keying tools, but that was just a quick hack to see if spill suppression idea could be successful with your image, I couldn't really see where your CA was apart from white edges of flowers.
Yellow_ is offline   Reply With Quote
Old 25th August 2011, 14:53   #15  |  Link
bizz & buzz
Banned
 
Join Date: Jun 2008
Posts: 94
True, this is where the CA mostly is.
The Blender option looks interesting, I'll check it out!
Thanks
bizz & buzz is offline   Reply With Quote
Old 25th August 2011, 20:59   #16  |  Link
bizz & buzz
Banned
 
Join Date: Jun 2008
Posts: 94
Thanks Rean! Tried EdgeDesaturate() and it's working fine, but it seems to have only a minor effect on the CA, even when setting Aggressive=True.
bizz & buzz is offline   Reply With Quote
Old 30th August 2011, 13:49   #17  |  Link
Emulgator
Big Bit Savings Now !
 
Emulgator's Avatar
 
Join Date: Feb 2007
Location: close to the wall
Posts: 1,531
Quote:
Unfortunately this filter doesn't seem to remove this particular CA...
BTW, FixChomaticAberration unfortunately does not apply radial stretching:
Code:
 # This AviSynth function stretches the red, green and/or blue channel according to
 # a given factor symmetrically around the center of the frame and crops it afterwards.
 #
 # Parameters: clip, red, green, blue. 
 # red, green and blue are stretching (resizing) factors against the original clip size.
 #
 # The function returns the clip in RGB24 colorspace.
 ## (Emulgator: this is true now since my fix from 07.August 2010, before it defaulted to RGB32.)
 #
 # Factors of e.g. red=1.015, green=1.01 allow to compensate the colored edges near the
 # corners of the image which appear from lenses with 'chromatic aberration'.
 #
 # If a factor is below 1.0, a that color will be fitted with black corners into the frame. 
 #
 # x and y allow to set the center of the aberration circle.
 # It defaults to the center of the image.
 #
 ## Emulgator: The latter is not true, since width and height have not been handed over as function parameters.
#(Late edit: I was wrong. Default is center of image)
 ## I prefer to give x and y as width/2 and height/2 anyway before calling this function.
#(Late Edit: This allows for offset center)
 ## If the impression exists that this function would stretch radially this holds not true either.
 ## Only linear stretching along x and y axis is performed.
 #
 # Note that chromatic aberration also smears the image a bit, which is not compensated
 # by this function.
 #
 # Martin Wagener at gmx.de, 04/09/2007
 # fixed by Emulgator 07.August 2010
__________________
"To bypass shortcuts and find suffering...is called QUALity" (Die toten Augen von Friedrichshain)
"Data reduction ? Yep, Sir. We're that issue working on. Synce invntoin uf lingöage..."

Last edited by Emulgator; 30th August 2011 at 15:27.
Emulgator is offline   Reply With Quote
Old 30th August 2011, 14:38   #18  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by Emulgator View Post
Code:
 # x and y allow to set the center of the aberration circle.
 # It defaults to the center of the image.
 #
 ## Emulgator: The latter is not true, since width and height have not been handed over as function parameters.
Huh? The width and height are got from the clip itself:
Code:
     c= (IsRGB(clip)) ? clip : ConvertToRGB(clip)
     w= c.Width()
     w2= round(w*0.5)
     h= c.Height()
     h2= round(h*0.5)
     xi= default(x,w*0.5)
     xi= (xi<0)?0:xi
     xi= (xi>=w)?w-1:xi
     yi= default(y,h*0.5)
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 30th August 2011, 15:14   #19  |  Link
Emulgator
Big Bit Savings Now !
 
Emulgator's Avatar
 
Join Date: Feb 2007
Location: close to the wall
Posts: 1,531
As I tried it the first time it did not work as expected. Lets see...
P.S. Yes, it works as promised and defaults to image center.

I guess I wanted to have the center offset back then and started to edit the script.
Will have to edit my findings regarding centering.

What about the radial stretching ?
__________________
"To bypass shortcuts and find suffering...is called QUALity" (Die toten Augen von Friedrichshain)
"Data reduction ? Yep, Sir. We're that issue working on. Synce invntoin uf lingöage..."

Last edited by Emulgator; 30th August 2011 at 15:24.
Emulgator is offline   Reply With Quote
Old 30th August 2011, 17:47   #20  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by Emulgator View Post
What about the radial stretching ?
I believe it does stretch radially, since for each color (R, G, B), the horizontal and vertical scaling factors are equal.

However, there is a slight inaccuracy in the centre point, since it doesn't take into account that Avisynth resizers maintain the image centre point rather than maintaining the top left position. It would also be better to combine the resize and crop in a single operation using floating point offsets. I don't have time to figure out the exact solution just now - I might get back to it later if no one else comes up with it.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:53.


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