Log in

View Full Version : Chroma Noise Filter


PaulD
8th October 2013, 10:58
First post - please be kind :)

I have the colour bands problem which is illustrated in section 12.4 (top picture) of the capture guide in doom9.net see http://www.doom9.org/capture/chroma_artefacts.html . At the end of this section it states that “at the time of writing this page there are no filters who can correct this”. Since the page was last edited in 2004, can anyone tell me if there is now a filter which can clear this problem?

Asmodian
9th October 2013, 00:22
Are you sure you don't have simple interlacing (http://www.neuron2.net/LVG/interlacing.html)? That image looks a lot like normal interlacing but it isn't.

There still isn't anything that can fix that error, as far as I know. However, interlacing is a very well researched problem and there are lots of ways to fix it. I like QTGMC for deinterlacing.

PaulD
9th October 2013, 09:39
Thanks for your reply. I've used the de-interlacer in VirtualDub, and that didn't shift it. I'll try QTGMC.

Asmodian
10th October 2013, 19:26
If you post a small unmodified sample we can take a look and offer advice. :)

PaulD
12th October 2013, 16:46
Thanks, very good of you. I don't think I can send a sequence via the forum but attached is a jpeg frame extracted from it which illustrates the problem. The bands are in the sky.

raffriff42
13th October 2013, 14:30
I dunno, looks like skew (tape tension) error maybe. Here's an experimental script that might help.
https://www.dropbox.com/s/ocyg8au39xlfjkt/chrnoise%20t%3D168957%20Example0100-fix2.jpg?raw=1 ## requires MaskTools2
LoadPlugin(pathBase + "MaskTools2\mt_masktools-26.dll")

## <<YV12 source>>

ChromaDestripe()
#return Last

## optional color correction
ConvertToRGB()
return MergeRGB(
\ ShowRed.Levels(0, 1.10, 255, 0, 255),
\ ShowGreen.Levels(0, 1.0, 255, 0, 255),
\ ShowBlue.Levels(0, 0.75, 200, 0, 255)
\ ).Levels(15, 1.2, 235, 0, 255)

#######################################
## remove horizontal chroma stripes
##
## @ top - number of pixels (from top) to process (default 160)
## @ blur - vertical chroma blur radius (default 12)
## @ thresh - ignore smaller chroma changes (default 6)
##
function ChromaDestripe(clip C, int "top", int "blur", int "thresh")
{
top = Max(0, Default(top, 160))
blur = Min(Max(2, Default(blur, 12)), 16)
thresh = Min(Max(0, Default(thresh, 6)), 32)

U = C.UToY8
V = C.VToY8
Y = C.ConvertToY8
#return Y

tw = V.Width
th = V.Height

## X = (highpass blurred anti-signal)

xh = Max(1, Round(th / 4))
XU=U.BilinearResize(tw, xh, src_top=1, src_height=(th-2))
\ .BilinearResize(tw, th)
XV=V.BilinearResize(tw, xh, src_top=1, src_height=(th-2))
\ .BilinearResize(tw, th)
#return XU

## H = highpass - find bold horizontal U & V edges

HU=U.Subtract(XU).Invert.ColorYUV(cont_y=98)
HV=V.Subtract(XV).Invert.ColorYUV(cont_y=98)
#return HU.Histogram

## M = mask - pass only areas with bold hor. U & V edges

MU=HU.mt_lut("x 128 - abs " + String(thresh) + " - 512 * ")
MV=HV.mt_lut("x 128 - abs " + String(thresh) + " - 512 * ")
#return MU

MU=MU.mt_expand
\ .BilinearResize(tw/4, th/4)
\ .mt_expand.mt_expand
\ .BilinearResize(tw, th)
MV=MV.mt_expand
\ .BilinearResize(tw/4, th/4)
\ .mt_expand.mt_expand
\ .BilinearResize(tw, th)
#return MU

## restrict mask to "top" pixels

top = top / 2
MU = (top<=0 || top>=th)
\ ? MU
\ : MU.Crop(0, 0, -0, top).AddBorders(0, 0, 0, (th-top))
MV = (top<=0 || top>=th)
\ ? MV
\ : MV.Crop(0, 0, -0, top).AddBorders(0, 0, 0, (th-top))
#return MU

## B = chroma blur

nh = Max(1, Round(th / blur))
BU=U.BilinearResize(tw, nh, src_top=1, src_height=(th-2))
\ .BilinearResize(tw, th)
BV=V.BilinearResize(tw, nh, src_top=1, src_height=(th-2))
\ .BilinearResize(tw, th)
#return BU

## use blurred chroma in areas of high variation

U=U.Overlay(BU, mode="blend", opacity=1.0, mask=MU)
#return U
V=V.Overlay(BV, mode="blend", opacity=1.0, mask=MV)

return YToUV(U, V, Y)
} I don't have any video around with this type of error, but the script helps the sample image and doesn't seem to hurt normal footage. With one exception: color bars get smeared.

Here's the progress of the U channel (most of the error in this example is in the U channel, but both channels are processed in the script)
https://www.dropbox.com/s/o9gd6zg4suofbkb/chrnoise%20t%3D168957%20Example0100-U-progress.png?raw=1

Mounir
14th October 2013, 23:16
Can you provide a video sample PaulD ?

PaulD
22nd October 2013, 15:29
Thanks for your script raffriff42. However I'm afraid I'm a complete novice at this and when I run Avisynth with the script I get the error message UVtoY: YUV data only!. Do you know what I'm doing wrong?

PaulD
22nd October 2013, 15:32
I've loaded an example on YouTube at: http://youtu.be/EK2x3zMKVdg

Can you provide a video sample PaulD ?

raffriff42
22nd October 2013, 17:33
Thanks for your script raffriff42. However I'm afraid I'm a complete novice at this and when I run Avisynth with the script I get the error message UVtoY: YUV data only!. Do you know what I'm doing wrong?
You need a statement in the script to replace the placeholder ## <<YV12 source>>
First see this page: Your first Avisynth script (http://avisynth.nl/index.php/First_script). Work at the example script on that page (you may need a different "source" plugin as explained in the link) until you can successfully "play" your script with Windows Media Player, VirtualDub etc. Then check if your source is YV12 (http://avisynth.nl/index.php/YUV) or not:<<source>>
Info...which will put a text overlay on the screen. Look for "ColorSpace: YV12" - if ColorSpace is something else, add a new line: <<source>>
ConvertToYV12

OK, now that's done, go back to the script I posted and replace the placeholder source statement.

The next issue is downloading & installing the required plugin, MaskTools2 (http://forum.doom9.org/showthread.php?p=701539). If mt_masktools-26.dll is copied to the Avisynth plugins folder you can delete the "LoadPlugin" line, otherwise edit the "LoadPlugin" line to load mt_masktools-26.dll from wherever you have it.

If all this is done correctly the script should run...

lansing
22nd October 2013, 18:28
virtualdub's camcorder color denoise is the one you're looking for

PaulD
23rd October 2013, 12:32
Thanks raffriff42. It was the convert line I was missing. It now works, and the output is much improved. :thanks: