View Single Post
Old 15th September 2007, 02:41   #1  |  Link
tritical
Registered User
 
Join Date: Dec 2003
Location: MO, US
Posts: 999
NNEDI - intra-field deinterlacing filter

Well, here is nnedi v1.3. It isn't perfect yet, but I think it definitely proves that this method can work well. A v2.0 is already in the works. The filter operation is pretty simple... it throws away one field of each input frame and then interpolates the missing pixels. There is a parameter called 'field' to control which field is kept and double vs same rate output (same as the field parameter in eedi2). Then there are boolean Y, U, and V parameters to control which planes are processed.

This filter turned out to be pretty good for resizing as well (limited to powers of 2 enlargement). Using it for resizing is pretty easy... pointresize the height to 2x, use nnedi, rotate left or right, pointresize again, use nnedi a second time, etc... It is slightly more difficult for YUY2 because turnleft()/turnright() will mess up (blur/interpolate) the chroma. So you will need to use utoy() and vtoy() to pull the chroma planes out and then process each of the 3 clips separately. Example functions for 2x resizing:

Code:
function nnediresize2x(clip c, bool pY, bool pU, bool pV)
{
	v = c.nnedi(dh=true,Y=pY,U=pU,V=pV).turnleft()
	v = v.nnedi(dh=true,Y=pY,U=pU,V=pV).turnright()
	return v
}

function nnediresize_YUY2(clip c)
{
	cy = c
	cu = c.utoy()
	cv = c.vtoy()
	cy = nnediresize2x(cy,true,false,false)
	cu = nnediresize2x(cu,true,false,false)
	cv = nnediresize2x(cv,true,false,false)
	return ytouv(cu,cv,cy)
}

function nnediresize_YV12(clip c)
{
	return nnediresize2x(c,true,true,true)
}
This will result in a shifted image, the direction being dependent on the rotations used.

As an example, 4x enlargement of clown image from http://www.general-cathexis.com/interpolation.html. No pre or post processing.

Any feedback is welcome, and thanks again to everyone who contributed cpu time .

Last edited by tritical; 21st September 2007 at 00:26.
tritical is offline   Reply With Quote