Printable Version of Topic
Click here to view this topic in its original format
Unofficial VirtualDub Support Forums > General programming > How To Write A Custom Denoise Filter?


Posted by: istvan Feb 8 2012, 11:51 PM
I have an old wedding video. It seems that the original tape has the noise on it, unfortunately is a PAL tape, so I do not have too many players tor try.. It has a random noise similar to VHS player tracking error. the noise has a form of a bright white raindrop or fish, with the left side the head ( a little more bright) and the right side the tail. The size is very similar a couple of pixels high(3-4) and about 15-20 pixels long. I have analyzed the frames and it seems that the noise is always random and only in one frame, neither the frame after or the frame before have the noise at the same place. There are about 4-5 of this noise items on each frame. I tried a couple of commercial filters , but most of them do some temporal averaging, that reduces the noise, but does not eliminate it. Let's assume that I have a piece of the video without scene transitions. I am not concerned about the performance, this is a one time job.
About my background: I did some image processing and programming about 12 years ago, so I am somewhat able to write code, I hope...
I need some help:
I am thinking of a filter that:
- analyses each frame for a match for a pattern (that is preprogrammable).
-If a pattern is found it compares it with the frame before and the one after, to eliminate false "matches". As I said a match is only in one frame
-If I found a match I would replace the pixels with the average of the frame before and the one after. (The scenes are pretty static...) I could do match finding for the head only, and do correction on a slightly larger area.

Some of my questions:
-is there a filter that would be easy to change?
-Is there somewhere a HelloWorld filter, that I could use for start?
-Should I try to find the match in the luminance space?
-How to deal with the 3 frames needed for the filter? I would like to see the result in a preview window. This would allow me to write the match finder first, see interactively if it works, maybe have some adjustable parameters for size and threshold of noise.

How to deal with the interlaced picture (it has been imported using the analog input of a miniDV camcorder, so is miniDV AVI format.
-Should I convert it to non-interlaced first?
-Should I upconvert it to a higher resolution?

Any Ideas?

Posted by: dloneranger Feb 9 2012, 06:55 AM
In the SDK there's a sample filter that you can alter, also a lot of third party filters include the source code as well

In the virtualdub source code, the ITVC filter is an example of a filter that compares frames - it's 'reduce frame rate only' function is an understandable example of checking 5 frames and picking one to drop
You could see how the frames are compared there, and substitute the frame dropping and fps change for a ' blob' search and replace that with the average of the previous and next frame

Deinterlacing fisrt would probably be easiest

The preview window shouldn't bee too hard, you can output anything you like to the preview window
So, you could scale the 3 frames down and put them side by side - or just put a marker around and 'found' areas

If the speckles are white, if could be faster to run the filter in YUV and just check the Y plane for an erroneous high value that isn't on the previous and next frame

Posted by: phaeron Feb 11 2012, 08:27 PM
There are two ways you can prototype this, depending on what you're comfortable with. You can either write a VirtualDub filter directly, or you can have VirtualDub convert your video into raw video frames or image files so your program can process it and then convert its output back into a video file. If you have an existing framework or environment you're already comfortable with, the second option may be easier, and you can rewrite the algorithm as a video filter later.

Posted by: levicki May 14 2012, 11:02 PM
Or if the recording is not too long, you could export all frames to images and retouch the damaged ones using Photoshop healing or clone brush. That would probably take less effort and time than writing temporal feature recognition and removal plugin (unless you already have experience with that kind of programming).

Powered by Invision Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)