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 13th August 2005, 11:50   #1  |  Link
markshanks
Registered User
 
Join Date: Aug 2005
Posts: 4
Possible to use avisynth to eliminate dead pixels on video?

Hi there,

I have a digital video camera, and unfortunately it now has ONE dead pixel on the CCD. This results in an always white pixel on any video I have recorded. Depending on the scene, it can be very distracting.

It would in fact be easy to fix this. All I need is software where you can specify the location of the dead pixel, and it will then change its colour to that of the average of the surrounding pixels. I am sure that this would completely eliminate the problem in almost all (if not completely all) situations.

Question 1:

Would avisynth be able to do this? I have not used avisynth before but someone on usenet suggested it might be able to.

Question 2:

If so, would someone who is familiar with avisynth be able to write the appropriate script or whatever is required (assuming it is a two-minute job once you are familiar with the program)?

I think that such a program would be useful for quite a few people - when I posted this question on usenet a couple of other people said they had the same problem, and it would be better to find a software solution rather than throwing away a camera that cost thousands of dollars.


Thanks,

Mark
markshanks is offline   Reply With Quote
Old 13th August 2005, 12:00   #2  |  Link
Bester
Psi-Corps
 
Bester's Avatar
 
Join Date: Jul 2005
Posts: 46
The first that comes in my mind:

Locate the pos of the px. Build a mask ( with px=white, rest=black)
and then use

overlay(clip,clip,y=1,mask=your_mask)

The "wrong" px will be replaced by the px above.
Bester is offline   Reply With Quote
Old 13th August 2005, 12:47   #3  |  Link
AVIL
Registered User
 
Join Date: Nov 2004
Location: Spain
Posts: 401
Hi markshanks,

You can try also the filter Removegrain from kassandro. With mode=1 it sets the value of every pixel in the scope min-max of their eight neighbours. So, your white pixel will be changed by another similar to the environment. You be carefull that this action is performed on the whole frame, not only on your bad pixel. Usually, this effect is positive. If not, you can use a mask to recover the previous value for the rest of the pixels.

Good luck and wellcome.
AVIL is offline   Reply With Quote
Old 16th August 2005, 13:37   #4  |  Link
markshanks
Registered User
 
Join Date: Aug 2005
Posts: 4
Okay, finally got avisynth to work and am very encouraged. I usually edit in premiere, and then convert the dv to mpeg using tmpgenc, so it is very easy to use avisynth as input to tmpgenc and the slow down isn't a hassle as the conversion to mpeg is slow to begin with.

I also worked out how to run removegrain and this does indeed greatly reduce the visibility of the dead pixel. However, I dislike doing removegrain to the whole frame, as it does soften the image slightly and results in a very slight loss of detail.

I tried to work out how to do a mask so that removegrain would only be applied to the offending pixel, but couldn't work out how you define the mask. When you look up mask in the help, it simply takes you to the layer command which I presume you use to combine the images after you have defined the mask and applied the filter to the unmasked area.

How does one actually define a mask (assuming that is what you need to do) so that removegrain only works on a single pixel or a few pixels?
markshanks is offline   Reply With Quote
Old 16th August 2005, 13:39   #5  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,607
or try undot()
__________________
Don't forget the 'c'!

Don't PM me for technical support, please.
scharfis_brain is offline   Reply With Quote
Old 16th August 2005, 14:04   #6  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,390
RemoveGrain(1) == Undot() [YV12 source]
RemoveGrain(1,0) == Undot() [YUY2 source]

If the pixel is always white, a possibility much faster then doing any masking is using a filter from the MaskTools (just 'import()' it in your script) to apply the RemoveGrain-filtering only to white pixels:

YV12Lutxy(last,last.removegrain(1),"x 234 > y x ?","y","y",U=3,V=3)
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 16th August 2005, 19:55   #7  |  Link
kassandro
Registered User
 
Join Date: May 2003
Location: Germany
Posts: 502
Quote:
Originally Posted by markshanks
Hi there,

I have a digital video camera, and unfortunately it now has ONE dead pixel on the CCD. This results in an always white pixel on any video I have recorded. Depending on the scene, it can be very distracting.
A digital video camera probably produces interlaced video. On the other hand, Undot or RemoveGrain(mode=1) is for progressive video only. This would explain your complaints about this filters. You would be the first at all, who claims that Undot or RemoveGrain(mode=1) is to aggressive on progressive footage. The denoiser in a high resolution digicam is probably much more aggressive.
If RemoveGrain(mode=1) removes the dead pixel, then it must be truely a single and I can easily write a filter for this problem. In the progressive case the solution is obvious. RemoveDeadPixel(x=321, y=64) applies RemoveGrain(mode=12) (but without the center pixel) solely to the pixel with coordinates (321,64). In the interlaced case one can think of more sophisticated solutions.

Last edited by kassandro; 16th August 2005 at 20:02.
kassandro is offline   Reply With Quote
Old 16th August 2005, 23:25   #8  |  Link
Bester
Psi-Corps
 
Bester's Avatar
 
Join Date: Jul 2005
Posts: 46
Quote:
Originally Posted by markshanks

How does one actually define a mask (assuming that is what you need to do) so that
removegrain only works on a single pixel or a few pixels?
It seems I only post Overlay stuff...

Mask:
You could cap an image of your vid, eg. with virtualdup as sequ. bmp.
Open your bmp in "paint" or another prog.
Paint the dead px or the region that should be processed as white, the others black.
Save it.

Script sth. like

dv=directshowsource(...)
mask_bmp=Imagereader(...)

dv_with_filter=dv.filter()

overlay(dv,dv_with_filter, mask=mask_bmp)
Bester is offline   Reply With Quote
Old 17th August 2005, 03:14   #9  |  Link
markshanks
Registered User
 
Join Date: Aug 2005
Posts: 4
Dear kassandro,

Sorry, I should have confirmed that I am using progressive video.

Can you write the filter you suggest? As I said, I am sure that it would be helpful to other people as well.

Incidentally, when I made the point about removegrain losing detail, this was only visible in some scenes, and only when I had still frames next to each other (one with removegrain, one without) to compare. Even then, it was very subtle, and I may have been imagining the difference. The main reason I would prefer to just target the pixel is then I don't need to be concerned that removegrain is removing detail in some situations that I have not specifically examined, ie, more of being on the safe side without extensively studying the effects of removegrain.

Again, I think the filter you suggest would be the easiest and best solution if you can write it.
markshanks is offline   Reply With Quote
Old 17th August 2005, 06:14   #10  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,547
this'd be a great thing to have in a plugin specify which dot is dead (possibly in an ini file or something similar) and the plugin interpolates around it while ignoring the rest of the video. should be really fast because only a few pixels are processed, and everything else is just copied.

one thing that concerns me slightly - ringing in the DV codec. even if the white pixel is fixed there'll still be the mosquito noise that it caused surrounding it. i think a filter could even handle this if it's clever enough and DV specific (there'll be a fair idea about where the mosqiuto noise will occur seeing as the pixel never moves).
__________________
sucking the life out of your videos since 2004
Mug Funky is offline   Reply With Quote
Old 17th August 2005, 07:07   #11  |  Link
kassandro
Registered User
 
Join Date: May 2003
Location: Germany
Posts: 502
RemoveDeadPixels

You can download the RemoveDeadPixels plugin from here. It can be used as follows:
Code:
RemoveDeadPixels(clip input, int x, int y, int "select", int ycolor, int vcolor, int ucolor)
.
The first three variables are mandatory and self explanatory. With "select" you what you want to interpolate. 1 = interploate Y value, 2 = interploate U value, 4 = interploate V value. If you want to interpolate all, then choose select = 1 + 2 + 4 = 7. If ycolor >= 0 then RemoveDeadPixels creates a dead pixel at the specified location. I needed this option for testing and you can use it for locating a dead pixel ycolor=0 creates a dead black pixel and ycolor=255 creates a dead white pixel.
Because YUY2 is the native color space of DV and digicam clips, the plugin is for YUY2 only. When I have time, I extend the plugin to handle several dead pixels in one stroke.
Here is an example script:
Code:
avisource("my_yuy2.avi", pixel_type="yuy2")
RemoveDeadPixels(100, 200, 7, 230) # creat a dead pixel
RemoveDeadPixels(100, 200, 7) # and remove it
Instead of simple averaging RemoveDeadPixels inspects all four lines through a pixel and selects that line for interpolation, where the distance between the two neighbours is minimal.

Due to conflicts with one moderator, I no more support my plugins within the doom9 forum. If you want support, go to my free speech support forum (you find a link on the RemoveGrain/RemoveDirt web sites).
kassandro is offline   Reply With Quote
Old 17th August 2005, 07:18   #12  |  Link
kassandro
Registered User
 
Join Date: May 2003
Location: Germany
Posts: 502
Quote:
Originally Posted by Mug Funky
this'd be a great thing to have in a plugin specify which dot is dead (possibly in an ini file or something similar) and the plugin interpolates around it while ignoring the rest of the video. should be really fast because only a few pixels are processed, and everything else is just copied.

one thing that concerns me slightly - ringing in the DV codec. even if the white pixel is fixed there'll still be the mosquito noise that it caused surrounding it. i think a filter could even handle this if it's clever enough and DV specific (there'll be a fair idea about where the mosqiuto noise will occur seeing as the pixel never moves).
Yes, RemoveDeadPixels is very fast. It doesn't contain code for deringing, though. On the other hand, I expect the bitrate to be high enough such that ringing isn't a visible problem. For instance, my Canon Powershot S1 needs over 100 MB for 1 minute (mjpeg 640x480@30 fps).
kassandro is offline   Reply With Quote
Old 17th August 2005, 12:27   #13  |  Link
markshanks
Registered User
 
Join Date: Aug 2005
Posts: 4
Hi Kassandro,

I have posted feedback for your Removedeadpixels plugin at the Removegrain/Removedirt forum you suggested.

Cheers,

Mark
markshanks 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 20:03.


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