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 3rd June 2010, 00:05   #21  |  Link
Blue_MiSfit
Derek Prestegard IRL
 
Blue_MiSfit's Avatar
 
Join Date: Nov 2003
Location: Los Angeles
Posts: 5,816
wow. Nice job guys
Blue_MiSfit is offline   Reply With Quote
Old 3rd June 2010, 00:09   #22  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 4,629
*.mp4 guy - very impressive. I can't remember a better example of targetting noise virtually perfectly

I would love to learn how you approached this and about the functions used, but they are beyond my level of knowledge of avisynth. I can read all the documentation until my face turns blue, but that doesn't tell me how to use it properly
poisondeathray is offline   Reply With Quote
Old 3rd June 2010, 03:28   #23  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,350
Quote:
Originally Posted by poisondeathray View Post
I can read all the documentation until my face turns blue, but that doesn't tell me how to use it properly
The best advice I can give you is to use it improperly until you start to get an idea of what it does. Also when threads like this pop up, try to find a solution, working from what you already know, and what other people are doing.

Quote:
Originally Posted by poisondeathray View Post
I would love to learn how you approached this and about the functions used.
In this case I just applied two things I've already "figured out". A FIR filter to be a more optimal blur then gaussian or box, and a soft thresholded median taken from a previous script and modified to work on the correct pixels (as found working on the FIR filter). I went through a few brain dead iterations of how to design the FIR filter, but it was pretty easy. Then I pulled the MT_Luts soft-thresholded median from another script, modified it to target the pattern (just switching it to run on the same group of pixels as the FIR filter). The soft-median worked pretty well when directly applied to the source as did the FIR filter, but luckily (and predictably) they were good at different things. I went through a few square-peg-round-hole iterations of how to combine them (using them separately, then doing overly complicated stuff to combine the results) before I figured out I was being stupid and I should just run the median on the difference between the source and the FIR, allowing me to add most of the detail removed by the blur back after median filtering it.

Thinking about how badly denoisers worked on this source, I added fft3d to the mix, using it to remove detail from the noise pattern isolated by the median filter, before subtracting said pattern from the blur-difference clip. I set up fft3d with low block width (low ability to target the pattern) and normal block height, then I set it to be spatial only, and tried to find which sigmas would correspond to the pattern, in this case it was sigma2, then I found the maximum value of sigma2 that wouldn't touch the pattern, then I set all the other sigmas very high, to maximise detail removal from the pattern (detail recovery).

If that sounds complicated (IE, poorly explained), it wasn't (complicated) It was just a few random ideas of how to apply stuff I already knew well, and a bit of trial and error refinement until it worked.

Hopefully this was helpful (I doubt it) and doesn't make me look like a pompous idiot, but you did asked (unless you didn't).
*.mp4 guy is offline   Reply With Quote
Old 3rd June 2010, 09:02   #24  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,412
Thanks for the explanation, *.mp4 guy.
Quote:
Originally Posted by *.mp4 guy View Post
I went through a few brain dead iterations of how to design the FIR filter, but it was pretty easy.
Can you expand a bit on that. How did you arrive at those numbers?
Gavino is offline   Reply With Quote
Old 3rd June 2010, 13:48   #25  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 4,629
Quote:
Originally Posted by Gavino View Post
Can you expand a bit on that. How did you arrive at those numbers?
Exactly! I remember a couple of other threads where *.mp4 guy derived some coefficients out of thin air . I would like to know the process by which he got those

Anyways, thanks for trying to clarify, and nice job *.mp4 guy.
poisondeathray is offline   Reply With Quote
Old 4th June 2010, 02:09   #26  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,350
Quote:
Originally Posted by poisondeathray View Post
Exactly! I remember a couple of other threads where *.mp4 guy derived some coefficients out of thin air . I would like to know the process by which he got those
1 - Guess
2 - Check
3 - Go to 1


3 4 6 4 3 Used filter (original was multiplied by 16 for easy modification)
1 4 6 4 1 gaussian
0 1 1 1 0 box radius 1
2 2 3 2 2 box radius 1.5
1 1 1 1 1 box radius 2

After a while it gets easier to think of what a filter will look like, which makes the process faster, but it really is just guessing and checking. Sometimes I will use a program to generate arbitrary lowpass filter coefficients, but that is mostly a convenience thing.

If you want to know how to make FIR filters, spend some time fiddling with mt_convolution until you start to understand what does what.
*.mp4 guy is offline   Reply With Quote
Old 5th June 2010, 09:33   #27  |  Link
creamyhorror
Registered User
 
Join Date: Mar 2008
Posts: 118
And thus the age of mass targeted filter creation begins. (Ridiculous job, *.mp4 guy.)

Someone should write a GeneticConvolution program that generates FIR filters, gets the user to evaluate them for fitness, and iteratively improves them.
creamyhorror is offline   Reply With Quote
Old 11th June 2010, 00:25   #28  |  Link
markanini
Registered User
 
Join Date: Apr 2006
Posts: 297
@mp4 guy: Any chance you can make your fix into a function? Seems killer for periodic/pattern noise!
markanini is offline   Reply With Quote
Old 11th June 2010, 01:06   #29  |  Link
Lorax2161
Registered User
 
Lorax2161's Avatar
 
Join Date: Oct 2007
Location: Forest of the Trufulas
Posts: 37
I'll second the request for a function, but I'll go out on a limb and say this was probably a specific fix for a specific problem, and thus isn't a good candidate for a function. Hope I'm wrong.

Congrats to *.mp4 guy for a job well done.

(The "corduroy" forehead in post #1 reminds me of my cable reception, hence the vote for a function. )
Lorax2161 is offline   Reply With Quote
Old 11th June 2010, 11:21   #30  |  Link
pandy
Registered User
 
Join Date: Mar 2006
Posts: 1,044
Seems that his one works quite ok for "Stakes Larger Than Life"

DeFreq(show=0, fx=48.0, fy=0.0, dx=1, dy=0.75, sharp=50.0, cutx=50.0, cuty=75.0)
pandy is offline   Reply With Quote
Old 14th June 2010, 01:49   #31  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,350
Code:
function DeStripe(Clip C, int "rad", int "offset", int "thr")
{

	rad = Default(rad, 2)
	offset = Default(offset, 0)
	thr_ = Default(thr, 256)


	Blurred = Rad == 1 ? C.Mt_Convolution(Horizontal=" 1 1 1 ", vertical = " 1 ", u=1, v=1) : C
	Blurred = Rad == 2 ? offset == 0 ? C.Mt_Convolution(Horizontal=" 1 1 1 1 1 ", vertical = " 1 ", u=1, v=1) : C.Mt_Convolution(Horizontal=" 1 0 1 0 1 ", vertical = " 1 ", u=1, v=1) : Blurred
	Blurred = Rad == 3 ? offset == 0 ?  C.Mt_Convolution(Horizontal=" 1 1 1 1 1 1 1 ", vertical = " 1 ", u=1, v=1) : offset == 1 ?  C.Mt_Convolution(Horizontal=" 1 1 0 1 0 1 1 ", vertical = " 1 ", u=1, v=1) : C.Mt_Convolution(Horizontal=" 1 0 0 1 0 0 1 ", vertical = " 1 ", u=1, v=1) : Blurred
	Blurred = Rad == 4 ? offset == 0 ?  C.Mt_Convolution(Horizontal=" 1 1 1 1 1 1 1 1 1 ", vertical = " 1 ", u=1, v=1) :  offset == 1 ? C.Mt_Convolution(Horizontal=" 1 1 1 0 1 0 1 1 1 ", vertical = " 1 ", u=1, v=1) :  offset == 2 ? C.Mt_Convolution(Horizontal=" 1 1 0 0 1 0 0 1 1 ", vertical = " 1 ", u=1, v=1) : C.Mt_Convolution(Horizontal=" 1 0 0 0 1 0 0 0 1 ", vertical = " 1 ", u=1, v=1) : Blurred
	Blurred = Rad == 5 ? offset == 0 ?  C.Mt_Convolution(Horizontal=" 1 1 1 1 1 1 1 1 1 1 1 ", vertical = " 1 ", u=1, v=1) :  offset == 1 ?  C.Mt_Convolution(Horizontal=" 1 1 1 1 0 1 0 1 1 1 1 ", vertical = " 1 ", u=1, v=1) :  offset == 2 ?  C.Mt_Convolution(Horizontal=" 1 1 1 0 0 1 0 0 1 1 1 ", vertical = " 1 ", u=1, v=1) :  offset == 3 ?  C.Mt_Convolution(Horizontal=" 1 1 0 0 0 1 0 0 0 1 1 ", vertical = " 1 ", u=1, v=1) : C.Mt_Convolution(Horizontal=" 1 0 0 0 0 1 0 0 0 0 1 ", vertical = " 1 ", u=1, v=1) : Blurred
		Diff = Mt_Makediff(C, Blurred)

	THR=string(thr_)
	MedianDiff =  Rad == 1 ? MT_Luts(Diff, Diff, mode="med", pixels = " 0 0 1 0 -1 0 " ,  expr = " X Y - X Y - X Y - abs 1 + * X Y - abs 1 + "+THR+" 1 >= "+THR+" 0.5 ^ "+THR+" ? + / - 128 +", u=1,v=1) : Diff
	MedianDiff =  Rad == 2 ? offset == 0 ?  MT_Luts(Diff, Diff, mode="med", pixels = " 0 0 1 0 -1 0 2 0 -2 0 " ,  expr = " X Y - X Y - X Y - abs 1 + * X Y - abs 1 + "+THR+" 1 >= "+THR+" 0.5 ^ "+THR+" ? + / - 128 +", u=1,v=1) : MT_Luts(Diff, Diff, mode="med", pixels = " 0 0 2 0 -2 0 " ,  expr = " X Y - X Y - X Y - abs 1 + * X Y - abs 1 + "+THR+" 1 >= "+THR+" 0.5 ^ "+THR+" ? + / - 128 +", u=1,v=1) : MedianDiff
	MedianDiff =  Rad == 3 ? offset == 0 ?  MT_Luts(Diff, Diff, mode="med", pixels = " 0 0 1 0 -1 0 2 0 -2 0 3 0 -3 0 " ,  expr = " X Y - X Y - X Y - abs 1 + * X Y - abs 1 + "+THR+" 1 >= "+THR+" 0.5 ^ "+THR+" ? + / - 128 +", u=1,v=1) : offset == 1 ? MT_Luts(Diff, Diff, mode="med", pixels = " 0 0 2 0 -2 0 3 0 -3 0 " ,  expr = " X Y - X Y - X Y - abs 1 + * X Y - abs 1 + "+THR+" 1 >= "+THR+" 0.5 ^ "+THR+" ? + / - 128 +", u=1,v=1) : MT_Luts(Diff, Diff, mode="med", pixels = " 0 0 3 0 -3 0 " ,  expr = " X Y - X Y - X Y - abs 1 + * X Y - abs 1 + "+THR+" 1 >= "+THR+" 0.5 ^ "+THR+" ? + / - 128 +", u=1,v=1) : MedianDiff
	MedianDiff =  Rad == 4 ? offset == 0 ?  MT_Luts(Diff, Diff, mode="med", pixels = " 0 0 1 0 -1 0 2 0 -2 0 3 0 -3 0 4 0 -4 0 " ,  expr = " X Y - X Y - X Y - abs 1 + * X Y - abs 1 + "+THR+" 1 >= "+THR+" 0.5 ^ "+THR+" ? + / - 128 +", u=1,v=1) : offset == 1 ?  MT_Luts(Diff, Diff, mode="med", pixels = " 0 0 2 0 -2 0 3 0 -3 0 4 0 -4 0 " ,  expr = " X Y - X Y - X Y - abs 1 + * X Y - abs 1 + "+THR+" 1 >= "+THR+" 0.5 ^ "+THR+" ? + / - 128 +", u=1,v=1) : offset == 2 ?  MT_Luts(Diff, Diff, mode="med", pixels = " 0 0 3 0 -3 0 4 0 -4 0 " ,  expr = " X Y - X Y - X Y - abs 1 + * X Y - abs 1 + "+THR+" 1 >= "+THR+" 0.5 ^ "+THR+" ? + / - 128 +", u=1,v=1) : MT_Luts(Diff, Diff, mode="med", pixels = " 0 0 4 0 -4 0 " ,  expr = " X Y - X Y - X Y - abs 1 + * X Y - abs 1 + "+THR+" 1 >= "+THR+" 0.5 ^ "+THR+" ? + / - 128 +", u=1,v=1) : MedianDiff
	MedianDiff =  Rad == 5 ? offset == 0 ?  MT_Luts(Diff, Diff, mode="med", pixels = " 0 0 1 0 -1 0 2 0 -2 0 3 0 -3 0 4 0 -4 0 5 0 -5 0 " ,  expr = " X Y - X Y - X Y - abs 1 + * X Y - abs 1 + "+THR+" 1 >= "+THR+" 0.5 ^ "+THR+" ? + / - 128 +", u=1,v=1) : offset == 1 ?  MT_Luts(Diff, Diff, mode="med", pixels = " 0 0 2 0 -2 0 3 0 -3 0 4 0 -4 0 5 0 -5 0 " ,  expr = " X Y - X Y - X Y - abs 1 + * X Y - abs 1 + "+THR+" 1 >= "+THR+" 0.5 ^ "+THR+" ? + / - 128 +", u=1,v=1) : offset == 2 ?  MT_Luts(Diff, Diff, mode="med", pixels = " 0 0 3 0 -3 0 4 0 -4 0 5 0 -5 0 " ,  expr = " X Y - X Y - X Y - abs 1 + * X Y - abs 1 + "+THR+" 1 >= "+THR+" 0.5 ^ "+THR+" ? + / - 128 +", u=1,v=1) : offset == 3 ?  MT_Luts(Diff, Diff, mode="med", pixels = " 0 0 4 0 -4 0 5 0 -5 0 " ,  expr = " X Y - X Y - X Y - abs 1 + * X Y - abs 1 + "+THR+" 1 >= "+THR+" 0.5 ^ "+THR+" ? + / - 128 +", u=1,v=1) : MT_Luts(Diff, Diff, mode="med", pixels = " 0 0 5 0 -5 0 " ,  expr = " X Y - X Y - X Y - abs 1 + * X Y - abs 1 + "+THR+" 1 >= "+THR+" 0.5 ^ "+THR+" ? + / - 128 +", u=1,v=1) : MedianDiff
		ReconstructedMedian = mt_makediff(Diff, MedianDiff)
			Mt_AddDiff(Blurred, ReconstructedMedian)

Return(Mergechroma(Last, C, 1))
}

Don't ask me if it works, I didn't have much information to work with. thr is strength, rad is "how big are the (whatevers)" offset is "how far apart are they" rad goes from 1 to 5, offset from 1 to 4, thr from 1 to bignumber. Also its generic and therefore not very good.
*.mp4 guy is offline   Reply With Quote
Old 16th June 2010, 22:23   #32  |  Link
markanini
Registered User
 
Join Date: Apr 2006
Posts: 297
I tested your script on the image by the original poster. Seperation is'nt as strong as your custom coefficients but still better detail and seperation than the other "contest entries" in this thread.
I'm excited about this filter cause I've been looking for an avisynth filter for periodic noise like in scans of magazine prints and photos with honeycomb textures. I love how avisynth gurus on this board find clever solutions that work with well with compressed 8-bit sources where professional photo software ends up emphasizing the limits of the original.

A bug: Seems to cut off the image after 320 horizontal pixels.

EDIT: Cutting off was related to something else, please ignore my bug report.

Last edited by markanini; 18th June 2010 at 11:19.
markanini is offline   Reply With Quote
Reply

Tags
corduroy, ridge

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 13:57.


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