View Full Version : FilterMeister - Degrunge Filter


byRo
02-16-2006, 03:44 AM
Ah, the frequency thing. Fun, isn't it? I used Tom's code because it is wicked fast:

sourcecode\codelibrary\recursiveGauss4b-clean.ffp
I've been picking that code apart to understand it before using it. Yes, it is very neat.

I'm thinking of making a band-stop filter, which would be a filter equivalent of the quick degrunge trick (http://retouchpro.com/tutorials/?m=show&id=213).
I have read that with a "normal" convolution (not recursive) you can create a difference-of-Gaussians just by using the difference of the convolution factors. What I don't know is if there is a way to adapt the recursive code.

Any ideas?

Another question...
Codes for Gaussian blur seem to always use integer numbers. How do Photoshop (and others) treat sub-pixel divisions?


Stroker
02-16-2006, 05:37 AM
The de-grunging thing is a frequency trick. Basically getting rid of medium frequencies where the grunge lies, but keeping high frequency detail and low frequency shadow/light. That's what it looks like to me (passing glance).

Greg Apodaca has a *very* nice variation of this. Instead of Gauss for low, try Median. See TBone's tutorial on Greg's variation: More skin smoothing (warning - lots of images) (http://www.photoshoptechniques.com/forum/showthread.php?t=8822)

You can adapt the recursive Gauss code to do High Pass.
High Pass = Gauss - original + 128

That should get you going in the right direction. At least, I think it will...? Am I way off the mark?

How do Photoshop (and others) treat sub-pixel divisions?

Sub-pixel is all about interpolation. For the most part, it seems that Photoshop uses whatever interpolation you set in the preferences. FM can do sub-pixel with iget(). Or, in FM, you can use any interpolation that you feel like coding. I recently coded bi-linear and it was more than adequate. You will have to get into type casting, like doubles and floats.

edit:

I did try to get recursive Gauss to use fractional values for q. It kind of worked, but was mostly not good.

byRo
02-16-2006, 07:03 AM
The de-grunging thing is a frequency trick. Basically getting rid of medium frequencies where the grunge lies, but keeping high frequency detail and low frequency shadow/light. That's what it looks like to me (passing glance).Exactly! ;)
Greg Apodaca has a *very* nice variation of this. Instead of Gauss for low, try Median. See TBone's tutorial on Greg's variation: More skin smoothing (warning - lots of images) (http://www.photoshoptechniques.com/forum/showthread.php?t=8822)Median is great for blurring ner the edges. On the surfaces (not edges) is can often leave a hard edged bump and make things worse than before.
The de-gringe trick, however, falls apart at the edges :rolleyes:, so maybe I'll find a way to include the median there.
You can adapt the recursive Gauss code to do High Pass.
High Pass = Gauss - original + 128

That should get you going in the right direction. At least, I think it will...? Am I way off the mark?That's about it. Just don't know if it can be done in one pass, or have to save an intermediate copy of the image between applying one and the other.
Sub-pixel is all about interpolation. For the most part, it seems that Photoshop uses whatever interpolation you set in the preferences. I had rather suspected that. Shame, I thought maybe it would be something cool :cool:

Thanks,


Stroker
02-16-2006, 07:03 AM
Did a quick look for 'band-stop' because I wasn't sure. Now I've got a better grip on what you are after. Turns out Lum Frequencies does what you are looking for. But LF is a bit much. Besides, one of the major points of FM is doing things your own way instead of somebody elses. Right?

Some really quick-n-sleazy notes on using recursive Gauss code.


int radius = min(ctl(1),xw/2,yw/2)/scaleFactor;

float q = (float)(radius);
float b0 = 1.57825 + 2.44413*q + 1.4281*q*q + 0.422205*q*q*q;
float b1 = 2.44413*q + 2.85619*q*q + 1.26661*q*q*q;
float b2 = -(1.4281*q*q + 1.26661*q*q*q );
float b3 = 0.422205*q*q*q;


In that code, I divided radius by scaleFactor. The reason for /scaleFactor gets into the preview's zoom factor. This can get funky if you are not comfortable with absolute vs. relative.

Now, the variables following q are dependant on q. If you reassign radius for another pass, then you reassign q. If you reassign q, then you need to reassign the variables dependant on q. This little thing really threw me for a loop.

Also, if you are doing more than one pass, you will have to pay attention to what you are blurring and where you are putting it. Could be tile buffers or arrays.

Give HsY a break and go in frequency direction for a bit?

Cameraken
02-16-2006, 07:13 AM
Give HsY a break and go in frequency direction for a bit?

Thats fine by me Stroker. As long as we can get back to it later


Ken

Stroker
02-16-2006, 07:16 AM
Ah, Ro, you snuck me.

I've actually looked into Median and what I found actually scared me.
Median in a nutshell:
- grab all values and put into an array
- sort them either ascending or descending
- take the value in the middle of the array

If you use Bubble Sort, you are looking at a lot of cycles being chewed up for larger radii. If you use Quick Sort, you are looking at some monster code. Egads!

I'm actually kind of torn on Median vs. Gauss. Maybe talk about this another day. Besides, we have access to recursive Gauss and that gives *tremendous* bias right about now.

edit:
Ah! Snuck by Ken.
Yeah, Ken, we'll do that.
But you might have to remind me because I'm ADD like that.

edit2:

Freckles be gone!

byRo
02-16-2006, 07:24 AM
Give HsY a break and go in frequency direction for a bit?I think it is an area that has a lot of very useful applications, and is quite underdeveloped.
I still dream of implementing :eek: a 7-band graphic equalizer. It would be possible with a lot of repetitive code and / or a lot of memory, but that wouldn't be fun, would it?


dkcoats
02-16-2006, 08:19 AM
Reading this thread makes me feel like I've wandered into a party where everybody's speaking Klingon.

:dizzy:

dc

Cameraken
02-16-2006, 01:32 PM
Well it sounds like fun to me Rô.
It will give me something to do while I get my head round Lum-Sat.

This was exactly what I was thinking about when I asked about splitting frequencies.
So we have a start
- read Lum into an array
- use recursive Gauss for high blur
- High Pass the high bur
- another pass for low blur
- calculate the medium frequencies
- tweak, put back together, and output


I think the thing that may be a problem is the FilterMeister display window as it will only give a 100% view.

I found this site
http://www.mehdiplugins.com/english/localequalization.htm
It’s not much use to us but they have been written with Filtermeister or FF


Ken

byRo
02-16-2006, 05:40 PM
I've actually looked into Median and what I found actually scared me.
Median in a nutshell:
- grab all values and put into an array
- sort them either ascending or descending
- take the value in the middle of the array

If you use Bubble Sort, you are looking at a lot of cycles being chewed up for larger radii. If you use Quick Sort, you are looking at some monster code. Egads!Not sure if you can do the median separately in the x,y directions like the Gaussian blur.
IF you could - then as you sweep through the image in the x direction you only need to add one new element to your already sorted median group and take one out. Doing it right that must be quicker than re-sorting at every pixel.
Reading this thread makes me feel like I've wandered into a party where everybody's speaking Klingon.Please, don't get Stroker started - wanna bet he speaks Klingon too :ogre:.
I did look it up once (Wiki). It is a very wierd language. (and I've already had enough trouble learning Portuguese)

Cameraken, actually I did use that plug-in before finding the adaptive equalization at Reindeer Graphics (which has more sliders to play with).


Stroker
02-17-2006, 03:08 AM
I don't speak Klingon, but I do speak Gringo.See haa-blah ess-pan-ol'.

Going through this frequency thing is going to take a bit of time. That is, I need to think things through a bit more and organize. Maybe my brain will work on this while I'm sleeping. Yes, sometimes I dream in techno-babble.

For now, check this out:

OnFilterstart:{
//Info("isTileable %d",isTileable);
isTileable=0;
setZoom(1);
return false;
}

See the setZoom? It is set to 1 and that means preview at 100% no matter what you do because it is in the OFS structure. If you use scaleFactor like I showed eariler, you can comment out setZoom() in OFS. The preview won't be entirely accurate when you zoom out, but it will be close enough.

If you want to see something really cool, change:

isTileable=0;

to

isTilable=True;

What you see when you click Okay will be *very* relevant.

Adaptive Equalization by Reindeer is one of my favorites. I've used it in the past very successfully for some forensic things.

byRo
02-17-2006, 03:48 AM
See the setZoom? It is set to 1 and that means preview at 100% no matter what you do because it is in the OFS structure. If you use scaleFactor like I showed eariler, you can comment out setZoom() in OFS. The preview won't be entirely accurate when you zoom out, but it will be close enough.So now your a mind reader too?
I was going to ask about that last night, but the clock keeps whizzing round too fast.

Seems that any filter that depends on a slider with some measure in pixels, requires some trickery to get the preview accurate - or, otherwise, best just to clamp the preview to 100%.

If I understand this right, unless you take the necessary precautions the preview can be completely different to the applied filter.

If I am still understanding right then the precaution would be to scale everything up / down for the preview with the scaleFactor.

(let's go slow, I'm still waking up)


Stroker
02-17-2006, 06:01 AM
You got it, Roland. You can easily test this with the border code that Ken posted. If you got the yarbles for it, fix it with scaleFactor.

Let's see, the series goes something like this:

setZoom(1) = scaleFactor of 1 = 100%/1 = 100%
setZoom(2) = scaleFacotr of 2 = 100%/2 = 50%
setZoom(3) = scaleFactor of 3 = 100%/3 = 33%
setZoom(4) = scaleFactor of 4 = 100%/4 = 25%

All the way to 16, I believe.

byRo
02-17-2006, 05:28 PM
Still some things to work out, but I'm quite pleased with my first filter....

byRo's deGrunge trick (http://retouchpro.com/tutorials/?m=show&id=213) - :bigthmb: now packaged in a filter :cool:


Stroker
02-18-2006, 03:05 AM
Jeez, Roland, looks like you nailed it. I ran it through some paces and it seems to be a bit of alright. Way to steal some of my thunder. Kudos.

Now, deGrunge can already be done with stock tools. Can also be done with Lum Frequencies. But it sure feels good doing it your own way, eh? It's all your own nuts-n-bolts. Can you feel it? Can you?

Tomorrow I'll start back on my HsY thing. Hopefully soon you'll see some real goodness come of it. After that, I'm planning on some other convolution stuff.

Of course, I'll do my best to field any questions that come up regarding whatever.

Cameraken
02-18-2006, 06:57 AM
Well Done Rô
That was quick. And it works great. Your C knowledge obviously helped a lot.
Are you going to make it seven band?

I know exactly what Stroker means. I can almost see the pixels whizzing through the code.
That’s why I prefer to leave them as ffp files rather than 8bf files,

Stroker it Sounds like you have another genius in the family. Are you going to teach her Photoshop next?

Ken

byRo
02-28-2006, 09:16 PM
Ro.
Wow, great stuff, you are flying with this.More like madly running around and jumping up and down a lot.
The documentation always seems to stop just short of what I need. There's a whole load of things to discover, but it's an uphill struggle.
Maybe I'll put a list of questions together and see if Stroker can fill me in.

Yeah, but if it was easy it wouldn't be fun. Would it? :wink:


lphoto
09-04-2006, 02:47 PM
What am I missing here? I am trying to download the filter in the zip file and all I get is an attachment.php that says I am not registered. Are there some restrictions or something that I am not aware of?