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.

Domains: forum.doom9.org / forum.doom9.net / forum.doom9.se

 

Go Back   Doom9's Forum > Capturing and Editing Video > DV
Register FAQ Today's Posts Search

Reply
 
Thread Tools Search this Thread
Old 6th July 2003, 07:38   #1  |  Link
FredThompson
Registered User
 
FredThompson's Avatar
 
Join Date: Feb 2002
Location: Charlotte, NC USA
Posts: 1,988
AviSynth DV cleanup script

If you haven't been following the thread I've got about cleanup in the capture area, go take a look. Regardless of what you're doing with DV, you'll probably be quite stunned how much noise is there. The script is NOT refined yet. I know that. There are some sample grabs on my page at http://www.geocities.com/fredthompson6

If you shoot DV, you really should see what's happening. The results are getting VERY good.
__________________
Reclusive fart.
Collecting Military, Trains, Cooking, Woodworking, Fighting Illini, Auburn Tigers
FredThompson is offline   Reply With Quote
Old 8th July 2003, 08:49   #2  |  Link
Jazz
Stone Buddha
 
Jazz's Avatar
 
Join Date: Jul 2002
Location: Planet Hollywood
Posts: 64
The thread is here.
__________________
"Like... new information has come to light, man!"

The Big Lebowski
Jazz is offline   Reply With Quote
Old 8th July 2003, 09:22   #3  |  Link
FredThompson
Registered User
 
FredThompson's Avatar
 
Join Date: Feb 2002
Location: Charlotte, NC USA
Posts: 1,988
Oh, guess I should included that, huh?

The page is outdated. The unwanted artifacts shown in 2 of the screen grabs do NOT exist with the current script. GeoCities has been acting up so I haven't been able to edit the page. If you use the current script and frame server from NTSC DV source the image quality can be higher than if you write a DV file from the script because of the lossy nature of DV.

There IS one thing I'm still working on that's quite important for cleanup. The current script fuzzes up the last frame before a scene change. That should be fixed fairly soon.
FredThompson is offline   Reply With Quote
Old 9th July 2003, 23:24   #4  |  Link
zeus163
Registered User
 
Join Date: Apr 2002
Posts: 134
I can't wait to try this when I get home. I played around with it right before we left on vacation and my wife wasn't too pleased. I'm sure I'll have some questions about this when I get back as the end result on your web page looked fantastic and you are doing what I want to do. While the original capture isn't terrible, I'd like to be able to clean it up a bit.

Thanks and I'm sure I'll get back to you in a few weeks!
zeus163 is offline   Reply With Quote
Old 10th July 2003, 00:45   #5  |  Link
FredThompson
Registered User
 
FredThompson's Avatar
 
Join Date: Feb 2002
Location: Charlotte, NC USA
Posts: 1,988
Right now I'm working on fine-tuning and making the scripts more easily used by other people. Also, I'm working on some laserdisc capture issues. Can't get into too may details but anyone with laserdisc might be interested in the attacks on moire if we're successful.

Hope to have that page updated by the weekend then I'll start on a complete how-to set of instructions. I'll submit them to doom9 first because of the dl cap at GeoCities.
FredThompson is offline   Reply With Quote
Old 10th July 2003, 15:14   #6  |  Link
Xesdeeni
Registered User
 
Join Date: Aug 2002
Posts: 467
Fred, one of your images compares 4:1:1 to something else. But the problem you show is specific to your DV codec, not 4:1:1. I'm guessing the "something else" you compare it to is probably 4:2:2, but the same type of problem would show up there if the codec didn't interpolate the chroma. For some reason the DV codecs don't all do this for 4:1:1.

Just basic linear interpolation helps a lot, done after the DV codec. I think you can do this with AVISynth's separation of luminance and chrominance, although I couldn't figure out how to last year, so I wrote a plugin to play with. But I wasn't satisfied with that. I had a video where a red ball was on a blue rug, and the red and blue colors bled into one-another using linear interpolation.

Anyway, I got the idea to do a "luma follower" interpolation. The idea was that there might be enough information in the luminance for the interpolation of the chromanance to follow and do a better job. For example:

Contrived original 4:4:4 (C is representative of U and V):
Y 100 101 150 149 150
C 50 51 80 79 80

4:1:1
Y 100 101 150 149 150
C 50 80

Replicated (like in your example) 4:1:1 to 4:4:4
Y 100 101 150 149 150
C 50 50 50 50 80

Linear interpolated 4:1:1 back to 4:4:4
Y 100 101 150 149 150
C 50 58 65 73 80

Luma follow (linear) 4:1:1 back to 4:4:4
Y 100 101 150 149 150
C 50 50 80 80 80

Unfortunately, in reality the noise and sharpening of the camera and/or DV codec caused me to have to add a floor and ceiling, slowing down the already unoptimized code. And the results weren't as good as I thought they should be.

I don't have this plugin with me, but if you want to see the results, I'll try to remember to grab it. But in any case, you should try interpolating the chroma, or using a DV codec that does so.

Xesdeeni
Xesdeeni is offline   Reply With Quote
Old 10th July 2003, 15:42   #7  |  Link
FredThompson
Registered User
 
FredThompson's Avatar
 
Join Date: Feb 2002
Location: Charlotte, NC USA
Posts: 1,988
Yes, please, I'll be very interested to see what you've got. The comparison screenshot was with FlyVideo doing 4:2:0. At least, that's my understanding. I don't have that hardware.

The source is IanD who has recently been posting in the DV forum.

I've got a 2-frame clip from him with the second frame having the saturated red streak. What you are seeing is the result of the MainConcept codec. It's also visible with the Canopus and Panasonic codecs, Cnaopus having the worst performance.

If there's a way to filter, sure, I'd love help.

FWIW, I'm also now working on some laserdisc-specific denoising. Apparently, they can have a problem with moving moire.
FredThompson is offline   Reply With Quote
Old 10th July 2003, 18:27   #8  |  Link
FredThompson
Registered User
 
FredThompson's Avatar
 
Join Date: Feb 2002
Location: Charlotte, NC USA
Posts: 1,988
ok, site should be properly updated now. I've added the 2-frame sample of IanD's FlyVideo3000 capture from the Star Wars laserdisc. Frame 2 is the one that's causing problems with DV. All I did to create the screengrab problem was load his file into VirtualDub then save as MainConcept DV. The problem seems common to DV encoders but the amount of unwanted color varies.

Cleanup script has also been slightly modified.
FredThompson is offline   Reply With Quote
Old 11th July 2003, 13:25   #9  |  Link
Xesdeeni
Registered User
 
Join Date: Aug 2002
Posts: 467
I'm sorry, I forgot to grab my Luma Follow filter. But as penance, I've created an AVISynth script you can try:
Code:
AVISource("FlyVideoStarWars-MCDV.avi")
#chroma = BilinearResize(180,480).BilinearResize(720,480)
#chroma = BicubicResize(180,480).BicubicResize(720,480)
chroma = LanczosResize(180,480).LanczosResize(720,480)
MergeChroma(chroma)
See what you think.

Xesdeeni
Xesdeeni is offline   Reply With Quote
Old 11th July 2003, 15:51   #10  |  Link
FredThompson
Registered User
 
FredThompson's Avatar
 
Join Date: Feb 2002
Location: Charlotte, NC USA
Posts: 1,988
I'll give it a shot.

This is resizing the chroma to 1/4 res then enlarging it to fit the full frame hoping rounding will get rid of some of the junk, right?

I forgot to mention that I've come to believe the only efficient way to work with filtered video is frame serving given the size of lossless storage or artifacts from lossy compression. Given those thoughts, it's not important to force the chroma into the 4:1:1 configuration.

Right now I'm not so concerned about absolute "perfect" chroma consistency from source to destination, I'm more interested in image quality. Have come to recognize that, just like physical pigment, removing "dirt" lightens the image. It's similar to cleaning a stained glass window or the effect when the Sistene Chapel was properly cleaned.

My filtering is using a mix of YUY2, YV12 and RGB colormodels out of necessity. Maybe AviSynth 3.0 will give an internal 4:4:4 mode and properly emulate other modes for interfacing with filters while properly handling oversampling. Uh...I mean the internal version stays 4:4:4 but will appear to any of the other 3 to suite the filter. Sort of like applying a 16-bit audio filter to a 96 kHz audio sample. That would be real cool.
__________________
Reclusive fart.
Collecting Military, Trains, Cooking, Woodworking, Fighting Illini, Auburn Tigers
FredThompson is offline   Reply With Quote
Old 11th July 2003, 18:24   #11  |  Link
Xesdeeni
Registered User
 
Join Date: Aug 2002
Posts: 467
Quote:
This is resizing the chroma to 1/4 res then enlarging it to fit the full frame hoping rounding will get rid of some of the junk, right?
Yes, kind of. The output of the DV codecs replicates the chrominance over four adjacent pixels. Instead, it would be better to interpolate. But without my filter (which I think was actually written for VirtualDub) you can't fix those samples. The next best thing is to do the above.

Umm...actually. Now that I look at it, the 180x480 downscale should really be just decimation. Hmmm. Can you do that in AVISynth?

Xesdeeni
Xesdeeni is offline   Reply With Quote
Old 11th July 2003, 18:40   #12  |  Link
FredThompson
Registered User
 
FredThompson's Avatar
 
Join Date: Feb 2002
Location: Charlotte, NC USA
Posts: 1,988
Dunno. I'll look into it tonight.

But....howsabout pointing me to your plugin. Can always load the VirtualDub and run it that way. Like I said, I'm not a stickler for absolute color match 'cause we're removing dirt so what's the "true" color?
__________________
Reclusive fart.
Collecting Military, Trains, Cooking, Woodworking, Fighting Illini, Auburn Tigers
FredThompson is offline   Reply With Quote
Old 11th July 2003, 20:23   #13  |  Link
Xesdeeni
Registered User
 
Join Date: Aug 2002
Posts: 467
I'm sorry, I forgot the filter at home. I'll try to remember to upload it from there.

Xesdeeni
Xesdeeni is offline   Reply With Quote
Old 14th July 2003, 04:03   #14  |  Link
Xesdeeni
Registered User
 
Join Date: Aug 2002
Posts: 467
If you can get it, it's at http://www.geocities.com/xesdeeni2001/411Helper.zip. If not, I'll try to update the main page to point at it tomorrow.

Xesdeeni
Xesdeeni is offline   Reply With Quote
Old 14th July 2003, 04:13   #15  |  Link
FredThompson
Registered User
 
FredThompson's Avatar
 
Join Date: Feb 2002
Location: Charlotte, NC USA
Posts: 1,988
Thanks. I'm working on the script right now, matter of fact. Looking to release it tomorrow.

That's when the fun starts, huh? Public release, I mean.
FredThompson is offline   Reply With Quote
Old 14th July 2003, 05:03   #16  |  Link
FredThompson
Registered User
 
FredThompson's Avatar
 
Join Date: Feb 2002
Location: Charlotte, NC USA
Posts: 1,988
Nuts, GeoCities is being a stickler. I noticed that with my page. They won't let you download directly, must have a link on a page hosted by them.
FredThompson is offline   Reply With Quote
Old 14th July 2003, 14:46   #17  |  Link
Xesdeeni
Registered User
 
Join Date: Aug 2002
Posts: 467
Try http://www.geocities.com/xesdeeni2001/index.html now.

Xesdeeni
Xesdeeni is offline   Reply With Quote
Old 15th July 2003, 00:01   #18  |  Link
FredThompson
Registered User
 
FredThompson's Avatar
 
Join Date: Feb 2002
Location: Charlotte, NC USA
Posts: 1,988
Hey, that's pretty cool.

Interpolation is the better of the 2 options for saturated red on black. The junk isn't removed, it's turned into more of a somewhat dampened blob. That's a huge improvement from the grid-like original.

I've not finished testing it inside my AviSynth scripting and am wondering how it will perform at the beginning of the filter chain. Maybe if it's first, followed by CNR2 and other noise filters, the red smear will be reduced even more. Can't test that wiht VirtualDub because VirtualDub filters come after the AviSynth processing.

Is this filter something you're open to actively working on?

I'm wondering how performance could change with an agressive weighting for very low luminence regions. The idea being this distortion is far more evident when the background should be black.

So...how about a way to dramatically decrease the chroma if the luma is very low a la DarkSmoother?
__________________
Reclusive fart.
Collecting Military, Trains, Cooking, Woodworking, Fighting Illini, Auburn Tigers
FredThompson is offline   Reply With Quote
Old 15th July 2003, 13:44   #19  |  Link
Xesdeeni
Registered User
 
Join Date: Aug 2002
Posts: 467
Quote:
Hey, that's pretty cool.

Interpolation is the better of the 2 options for saturated red on black. The junk isn't removed, it's turned into more of a somewhat dampened blob. That's a huge improvement from the grid-like original.
Well, I was hoping the luma follow would be better :|
Quote:
I've not finished testing it inside my AviSynth scripting and am wondering how it will perform at the beginning of the filter chain. Maybe if it's first, followed by CNR2 and other noise filters, the red smear will be reduced even more. Can't test that wiht VirtualDub because VirtualDub filters come after the AviSynth processing.
I'm pretty sure VirtualDub filters can be used just like AVISynth filters (except that they require RGB). All you do is use VirtualDubPlugin(). There shouldn't be any type of order issue.
Quote:
Is this filter something you're open to actively working on?
I kind of gave up when it looked like basic interpolation looked as good or better than the "luma follow." I don't have too much time nowadays, but I included the source if you want to have a try.
Quote:
I'm wondering how performance could change with an agressive weighting for very low luminence regions. The idea being this distortion is far more evident when the background should be black.
I don't know. It's difficult to reclaim lost information, especially when it is completely thrown out. Any assumption you make to reclaim it may be right for some images, but completely wrong for others. And remember, this is lossy compression, meaning you can never get out what was originally put in. In most cases, it's just a matter of getting something that looks good, not necessarily a duplicate of the original. In the case of your sample, the stair-step blockiness was obviously wrong. But the reconstructed version, even using the AVISynth script above, looks quite nice. It's not a duplicate of the original, but unless you put them side-by-side, will you really notice?
Quote:
So...how about a way to dramatically decrease the chroma if the luma is very low a la DarkSmoother?
That's probably easy enough, but then dark things will have less saturation. Theoretically, the original had the amount of saturation included in the chroma sample. And if the sub-sampled chroma happened to come from something lighter up against something darker, the "luma follow" should have allowed a sharper edge in the color. Perhaps I just didn't find the right algorithm.

There was another thing that always annoyed me about sub-sampled YUV space I have never actually experimented with. Say you have two pixels (assuming 4:2:2), one that is bright and one color, and right next is a dark and another color.
Code:
Y  192  10
C  red  blue
When the sub-sample is generated (sometimes the colors are averaged, sometimes they are dropped, but for this example, assume they are averaged), you get an equal weighting from both colors.
Code:
Y  192  10
C  yellow
But depending on how dark the second pixel is, the color may have been completely invisible. But it is weighted into the color as if it were brighter. I've always wondered if the conversion from 4:4:4 to 4:2:2 (or I guess 4:1:1, although I think the standard is to drop three colors instead of averaging), a darker pixel should be weighted less.
Code:
Y  192  10
C  red
This means when you convert back, your bright pixel will be closer to the right color. The darker one may be further away, but I think that is probably preferable to the brighter one being further away.
Code:
Y 192  10
C red  red
Anyway, the closest I've come to playing with this is the "luma follow." Since I'm pretty sure 4:1:1 drops three pixels, you'd get something like
Code:
Y  192  193    9   10   9   ...
C  red  red  blue blue blue ...

Y  192  193    9   10   9   ...
C  red                 blue ...
As I mentioned above, the "luma follow" should help when converting back
Code:
Y  192  193    9   10   9   ...
C  red  red  blue blue blue ...
But if the original colors were averaged, "luma follow" wouldn't really help:
Code:
Y  192  193    9   10   9   ...
C  yellow              blue ...

Y  192  193    9   10   9   ...
C  yel  yel  blue blue blue ...
Xesdeeni
Xesdeeni is offline   Reply With Quote
Old 15th July 2003, 18:44   #20  |  Link
FredThompson
Registered User
 
FredThompson's Avatar
 
Join Date: Feb 2002
Location: Charlotte, NC USA
Posts: 1,988
Yes, you are correct on many points

Maybe I didn't fully elaborate on the weighting idea. If you look at the comparision of FlyVideo and NTSC DV capture on this page: http://www.geocities.com/fredthompson6 you'll see the 4:1:1 distortion in all its glory.

That's where the color bleed looks worst, saturated colors on a black background. There's another example near the bottom of the page.

Well, I'm wondering about an area-based method to look at the surrounding luma and mess with the chroma as needed. If you've got:

red black black black black black black...

It should be easy enough to determine where to chop off the chroma.

Uh....black means near-black...

So it's really a horizontal-only analysis and the trigger is a string of near-black pixels.

Then again, maybe it won't work. I notice this much more when there's a lot of black so I'm assuming other people would also. Short gaps are a little different and that's where your example comes in.

Think of how DarkSmoother and ShadowSmoother work on only the very low luminence pixels. That's what I'm wondering about.
__________________
Reclusive fart.
Collecting Military, Trains, Cooking, Woodworking, Fighting Illini, Auburn Tigers
FredThompson is offline   Reply With Quote
Reply


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 17:52.


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