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 8th January 2015, 01:06   #1  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,695
Denoise odd fields more than even fields

I have a good quality NTSC VHS source that has more noise in the odd fields than the even fields:

More Noise in Odd fields (6 MB DV AVI file, hosted at MediaFire)

Just Bob or Separatefields() on this short clip, and you'll immediately see what I mean.

I am using MDegrain2, adapted from the sample given in the doc:
Code:
function MDegrain2i2(clip source, int "blocksize", int "over", int "denoising_strength", int "dct")
{
  overlap=default(over,0) # overlap value (0 to 4 for blksize=8)
  dct=default(dct,0) # use dct=1 for clip with light flicker
  fields=source.SeparateFields() # separate by fields

  prefiltered = RemoveGrain(fields,2)
  superfilt =   MSuper(prefiltered, hpad=32, vpad=32,pel=2)
  super=        MSuper(fields, hpad=32, vpad=32,pel=2)

  halfblksize= (blocksize>4)   ? blocksize/2 : 4
  halfoverlap= (over>2)   ? over/2 : 2

  bvec1 =  MAnalyse(superfilt, isb = true,  delta = 2, blksize=blocksize, overlap=over,dct=dct)
  bvec1 =  MRecalculate(super, bvec1, blksize=halfblksize, overlap=halfoverlap,thSAD=100) 

  fvec1 =  MAnalyse(super, isb = false, delta = 2, blksize=blocksize, overlap=over,dct=dct)
  fvec1 =  MRecalculate(super, fvec1, blksize=halfblksize, overlap=halfoverlap,thSAD=100)

  bvec2 =  MAnalyse(super, isb = true,  delta = 4, blksize=blocksize, overlap=over,dct=dct)
  bvec2 =  MRecalculate(super, bvec2, blksize=halfblksize, overlap=halfoverlap,thSAD=100)

  fvec2 =  MAnalyse(super, isb = false, delta = 4, blksize=blocksize, overlap=over,dct=dct)
  fvec2 =  MRecalculate(super, fvec2, blksize=halfblksize, overlap=halfoverlap,thSAD=100)

  denoised = fields.MDegrain2(super, bvec1,fvec1,bvec2,fvec2,thSAD=denoising_strength)

  Weave(denoised)
}
This function separates the interlaced video into fields, and then uses delta of 2 and 4 to match even fields with even, and odd fields with odd. I was hoping for a little insight into how to retain this elegant programming, while allowing me to apply a larger amount of noise reduction to the noiser field. I can certainly construct a monster, by duplicating this entire code block, applying a different amount of denoising, do a couple of SelectEvery(), and then interleave it back together, but I was hoping someone might have some more elegant ideas.

Thanks!
johnmeyer is offline   Reply With Quote
Old 8th January 2015, 11:55   #2  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
function MDegrain2i2(clip source, int "blocksize", int "over", int "denoising_strength", int "dct")
{
overlap=default(over,0) # overlap value (0 to 4 for blksize=8)
dct=default(dct,0) # use dct=1 for clip with light flicker
fields=source.SeparateFields() # separate by fields

prefiltered = RemoveGrain(fields,2)
superfilt = MSuper(prefiltered, hpad=32, vpad=32,pel=2)
super= MSuper(fields, hpad=32, vpad=32,pel=2)

halfblksize= (blocksize>4) ? blocksize/2 : 4
halfoverlap= (over>2) ? over/2 : 2

bvec1 = MAnalyse(superfilt, isb = true, delta = 2, blksize=blocksize, overlap=over,dct=dct)
bvec1 = MRecalculate(super, bvec1, blksize=halfblksize, overlap=halfoverlap,thSAD=100)

fvec1 = MAnalyse(super, isb = false, delta = 2, blksize=blocksize, overlap=over,dct=dct)
fvec1 = MRecalculate(super, fvec1, blksize=halfblksize, overlap=halfoverlap,thSAD=100)

bvec2 = MAnalyse(super, isb = true, delta = 4, blksize=blocksize, overlap=over,dct=dct)
bvec2 = MRecalculate(super, bvec2, blksize=halfblksize, overlap=halfoverlap,thSAD=100)

fvec2 = MAnalyse(super, isb = false, delta = 4, blksize=blocksize, overlap=over,dct=dct)
fvec2 = MRecalculate(super, fvec2, blksize=halfblksize, overlap=halfoverlap,thSAD=100)

denoised = fields.MDegrain2(super, bvec1,fvec1,bvec2,fvec2,thSAD=denoising_strength)

super2 = MSuper(denoised, hpad=32, vpad=32,pel=2)

denoised_s = denoised.MDegrain2(super2, bvec1,fvec1,bvec2,fvec2,thSAD=denoising_strength)

Weave (interleave (denoised.selecteven (), denoised_s.selectodd ()))
}

Last edited by feisty2; 8th January 2015 at 11:58.
feisty2 is offline   Reply With Quote
Old 8th January 2015, 17:36   #3  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,695
Thanks! That gave me enough of an idea to work out a solution that was even a little simpler. Much appreciated.
johnmeyer 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 12:07.


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