Log in

View Full Version : More Info on the SANDWICH Filter


slk001
25th September 2002, 15:53
I have been experimenting with the new SANDWICH filter and I have made some interesting observations about it.

With this statement,
SANDWICH(2)
I can get a noticeable reduction in the noise in my video - but, it also leaves noticeable artifacts (that I believe are due to a bug in the coding). I am enclosing a small .M2V clip (created with Premiere ~ 56 frames) that I have been using as a test platform. The clip is as follows:

10 frames of light blue screen.
1 frame of a white triangle and some white, single pixel dots.
10 frames of light blue screen.
1 frame identical to frame 11.
1 frame of a white horizontal bar.
10 frames of light blue screen.
1 frame with a multicolored "noise" streak.
10 frames of light blue screen.
2 frames identical to frame 11.
10 frames of light blue screen.

With SANDWICH(2),
Frame 11 is completely removed (as it should be).
Frame 22 is removed EXCEPT where it overlaps the white bar on the next frame (as it should be).
Frame 23 is removed EXCEPT where it overlaps the white triangles on the previous frame (as it should be), BUT it also exhibits some strange artifacts. These artifacts are hard to explain - just load up the file and see for yourself.
Frame 34 is completely removed (as it should be).
Frames 45 and 46 remain untouched (as they should be).

Now here's how to see the coding error I mentioned earlier. Use the command:
SANDWICH(50)

Now, the results of running this clip through the filter are as follows:
9 frames of light blue screen.
1 frame of a "shadow" of the next screen.
1 frame of light blue screen (where the triangle was correctly removed).
1 frame of the same shadow as in frame 10.
8 frames of light blue screen.
1 frame of a shadow of the triangle.
1 frame of the untouched parts of the triangle overlayed with a shadow of the white bar on the next frame.
1 frame of the untouched part of the bar overlayed with a shadow of the previous frame's white triangle.
1 frame of a shadow of the white bar.
8 frames of the light blue screen.
1 frame of a shadow of the streak.
1 frame of the light blue screen (where the streak was removed).
1 frame of a shadow of the streak.
8 frames of the light blue screen.
1 frame of a shadow of the next screen's triangle.
2 frames of the untouched triangles (as it should be).
1 frame of a shadow of the previous screen's triangle.
9 frames of the light blue screen.

I am sure that the artifacts are being caused by this temporal displacement of the objects that the program is examining. I am also sure (but I didn't check) that this is even occuring with the statement SANDWICH(2), but that they just not visible with my test clip with the naked eye.

I am using this script in my testing:

LoadPlugin("e:\program files\mpeg2dec\mpeg2dec.dll")
LoadPlugin("e:\program files\avisynth\sandwich.dll")
mpeg2source("I:\CARTOON TEMP I\PRE-SAND.D2V")

sandwich(50)

ResampleAudio(44100)

I view the results of this filter by opening the .AVS in VirtualDub (it gives me the ability to single step through the frames). I also can't get any of the other settings to work - except the SHOW. Could we change SHOW so that only the CHANGED PIXELS show up (instead of all the CHANGED NOT pixels)? Most are not changed and this results in a mostly solid purple page.

I believe that Simon is oh so close to having an EXCELENT noise reduction filter. If we can get these temporal bugs "quashed", we'll be there!

Si
25th September 2002, 17:26
Originally posted by slk001
Could we change SHOW so that only the CHANGED PIXELS show up (instead of all the CHANGED NOT pixels)? Most are not changed and this results in a mostly solid purple page.

While waiting for our clip to be approved I thought I address this question - the blocks in purple are not changed, so there is "nothing" to look at in these blocks :)

But I'll change it so Show = -1,0,1 and make Show = 1 indicate changed pixels and Show = -1 indicate unchanged pixels for all modes to make it consistant.

regards
Simon

Si
26th September 2002, 16:59
Ok - got your clip and can see the artifacts and I'll work out what's happening.

I couldn't open your .m2v file using mpeg2source - I evetually gave up and used DirectshowSource which has slowed me down a bit:(

Changing Show functionality is causing me a few problems as well:o

regards
Simon

slk001
26th September 2002, 18:11
Simon,
I have a clip of the ultimate use of the filter, but it is ~ 1.95MB in size. It is a laserdisk capture that has a very visible "bad" spot on the disk. The SANDWICH filter does a very good job of removing most of the noise. If you want to see it, I will try to send it to you via email.

Si
26th September 2002, 19:03
I don't think my hotmail account can handle large attachments :(
regards
Simon

Si
27th September 2002, 12:02
I believe the artifacts are due to the problems with the current alogorthim and not a programming bug :(

Because you've used such a low value of Threshold (so you don't get other problems) the filter can end up doing the following (taken from real values in the problem area)

Before Sandwich
Y1 U Y2 V
110 177 108 063 Light Blue Frame 22
232 128 232 128 White Frame 23
108 176 108 063 Light Blue again Frame 24

Sandwich will change the U, Y2 and V values in Frame 23 but because the Y1 difference is less than the Threshold(2), it will leave the Y1 value alone and you end up with :-

232 176 108 063
which makes the left hand pixel of the pair have the luminance value of the white bars but the chrominace values of the blue background. :(

I don't think I'll investigate Sandwich(50) because any problems with it are almost certainly due to the algorthim again :(

Maybe I need to check all the bytes that make up a pixel and if the filter decides to sandwich it then it should sandwich all the bytes that make up that pixel.

Also I need to try and understand understand SILICONS correction (in the original thread) to my understanding of his idea :confused:

regards
Simon