Log in

View Full Version : defringe function


PeaceAnt
23rd August 2009, 03:19
hi.

i wrote a simple function, that fixes color fringe in a clips recorded with wide conversion lens. i saw a plugin for gimp and i thought it should be very simple with avisynth. it just takes RGB channels and resizes them separately. it's not optimized yet. it could merge for example 4 RED channels into one picture and resize all four at once and the same for other channels. this function is only an idea, i know it's not perfect. it blurs resized channels a little, so it's a good idea to sharpen them. anyway here's the script:

function defringe(clip c, string ab, string rd, string gr, string bl)
{
eval("c.addborders("+ab+")")
eval("red=last.showred.lanczosresize(1280,720,"+rd+")
eval("green=last.showgreen.lanczosresize(1280,720,"+gr+")")
eval("blue=last.showblue.lanczosresize(1280,720,"+bl+")")
mergergb(red, green, blue)
}

#example:
defringe("5,1,5,1", "3,1,-3,-1", "5,1,-5,-1", "7,1,-7,-1")

because it isn't necessary to resize all channels you can simplify this function. it's not the point here. i ask you to help improve the idea. this resize used here is linear, but distortion of channels is not. i'd like to use my plugin "compound displace", that displaces pixels of a clip (in all channels separately) according to value of corresponding pixel in other clip (vector in horizontal and vertical axis). i used simple algorithm that calculates a weighted average (i think) of four pixels with subpixel precision (i think it could be done better) so we can now use a gradient to displace pixels in corners more than pixels near center and even define vectors for specific lens or focal lenghts. but the problem is blur occuring in processed channels, so maybe there are some better ideas?

http://img269.imageshack.us/img269/8661/poprawionee.png
original http://www.cs.mtu.edu/~shene/DigiCam/User-Guide/FZ-30/Converters/Wide-Test/Short/WA-Test-Short.html
http://img269.imageshack.us/img269/2058/poprawione.png
(almost) fixed


pozdrawiam

mikeytown2
25th August 2009, 21:12
Related Info
http://hugin.sourceforge.net/tutorials/tca/en.shtml
http://en.wikipedia.org/wiki/Chromatic_aberration