VF - Tools of the Trade

31 August 2010

We continue our discussion on visual frequencies by examining the "tools of the trade" which we'll use to bed these ideas to our will in practical retouching. To do so, though, we'll start like we did last time by introducing more traditional audio equivalents as well as some definitions.

In principle, we will demonstrate that, just as we were adding frequencies together to form new ones before, we can subtract components out of a whole. Consider the figure below adapted from yesterday. By subtracting the low frequency component out of the whole, we are left with a high frequency signal.

Sound subtraction demo

We can do that same thing with an image, subtracting out the low frequency portions to leave us only with the high frequency:

Image subtraction demo

This should be fairly intuitive - if we can add two things together to get a sum, we should be able to tease them apart too. But before we get too far into that, we really do need to spend some time going over the definitions of a few terms to make sure that we don't confuse things later on. For reference, all of the terms I'm going to use are from general signals processing, and are therefore applicable to sound as well as to images.
  • Bandstop filter - A filter which stops a frequency band from passing through it. Generally, which frequencies are blocked is selected (or 'tuned') by the user.
  • Bandpass filter - A filter which allows only a select frequency band to pass through it. Like the bandstop filter, the range which is allowed to pass is controlled by the user.
  • Lowpass filter - A filter which allows only frequencies which are lower than a selected value to pass through.
  • Highpass filter - A filter which allows only frequencies which are higher than a selected value to pass through.
Let's put those in context. Let's say that I have an arbitrary sound source which consists of four component tones as below:
  • a 25Hz tone
  • a 200 Hz tone
  • a 1,000 Hz tone
  • and a 10,000 Hz tone
Now, if we apply a highpass filter set to 500 Hz to that sound, which components are going to be left in the result? Only two portions - the 1,000 Hz and the 10,000 Hz tones. By allowing only frequencies above 500 Hz to pass through, we have eliminated the other two entirely from the result.

On the other side of things, by applying a lowpass filter with the same setting (500 Hz), we can eliminate the 1,000 Hz and the 10,000 Hz tones while keeping the 25 Hz and 200 Hz components (those frequencies which fall below the cutoff).

We'll take this one step further. If I apply a bandstop filter to this sound, configured to block from 100-5,000 Hz, which components will be left? Because I am allowing nothing above 100 Hz, nor anything below 5,000 Hz, I'm left only with the 25 Hz and 10,000 Hz tones in my final sound. Equally, if we were to apply a bandpass filter with those same settings, we would have eliminated the 25 Hz and 10,000 Hz components while retaining the 200 Hz and 1,000 Hz portions.

...

Whew - you made it! Now let's apply those definitions to Photoshop terms so that we can get back to something fun, shall we?

I don't think you'll be surprised, but the Photoshop High Pass filter is.... a highpass filter! Shocking, I know. On the other hand, what a lot of people don't know is that Gaussian Blur is its exact opposite - it is a lowpass filter.

Now, Photoshop doesn't have bandpass or bandstop filters per se, but that doesn't mean we can't create them ourselves. Think about it. A bandpass filter is nothing but lowpass and highpass filters operating on the same source. So, if we apply the High Pass filter to an image, followed by a Gaussian Blur, we have selected (or bandpassed) all the frequencies between them, creating a layer which contains only those portions of the image.

So what about the bandstop filter? Well, let's think for a second. From its definition, a bandstop subtracts out the frequencies which we've selected. And in the paragraph above, we figured out how to create a layer which only contains those frequencies. Now, if we go back to arithmetic (yes, it's math, but hold on - it's easy math), you'll remember that subtracting one value from another is the same as adding its inverse. So, if we invert (Image->Adjustments->Invert) the layer which we created above, we'll have transformed it from a bandpass filter into a bandstop layer. Neat, huh?

Let's look at some examples again before we wrap up for today. Some of what I'll show you will look very weird, but please accept it for what it is - we'll get into applications by the end of the week. For now, just focus on understanding what's going on with the image and what we're doing to get there.

The first series is an image you've already seen - the difference is that you now know what you're really looking at. The left is the whole image. In the center, the original image after we've applied a lowpass filter. On the right, the original image after applying a highpass filter.

Sound subtraction demo

Next, we see the original image on the left. In the center, I have applied a bandpass filter to the image, allowing through only select intermediate frequencies. The right shows what happens to the image when I transform the bandpass filter into a bandstop filter. Crazy looking, isn't it? But I promise, it's going to be something you'll love before long

Sound subtraction demo

We'll stop here for tonight. I've given you a lot of information to chew on and throwing too much more at you now is as likely to make things worse as it is better. Consider what we discussed, review it as you have time, and feel free to ask questions if you have them in your forum of choice. When we come back on Thursday (tomorrow is a soccer game!) we'll jump into how we actually go about making these filters in Photoshop.

So that you know what we'll be covering generally, let me give you the tentative schedule for the rest of this series:
  • Thursday Saturday - The Mechanics - the process to actual apply these filters in PS - there are some sticking points!
  • Saturday Sunday - Why Are We Doing This? - how these techniques can be used in real-world retouching and how to make the process easier for yourself
  • Sunday Monday - Dirty Truths and Dirty Tricks - highpass was just the beginning + all my lies laid bare
  • Monday onward - Q & A - whatever you ask!
(schedule subject to change depending on Hurricane Earl and
whether Pepco is actually ready for downed lines this time)

7 comments:

Anonymous said...

I'm loving these. Many thanks for the instruction. Finally someone is demystifying some of these tools for me. Still a bit confused with how to create the bandstop and bandpass and what to really do with all of them, but I know you'll be covering them. Now I have to wait for the next blog post.

Dragon Ink Photography

ana said...

Sorry, but:

"We'll take this one step further. If I apply a bandstop filter to this sound, configured to block from 100-5,000 Hz, which components will be left? Because I am allowing nothing below 100 Hz, nor anything above 5,000 Hz, I'm left only with the 200 Hz and 1,000 Hz tones in my final sound. Equally, if we were to apply a bandpass filter with those same settings, we would have eliminated the 25 Hz and 10,000 Hz components while retaining the 200 Hz and 1,000 Hz portions."

Maybe vice verse?

Sean said...

ana - You're right that that was a typo, and thank you for pointing it out to me! It wasn't exactly a full reversal, but was definitely some bad copy-paste :). The text has been corrected. Thank you!

Mike Serafin said...

Typo alert: "Now, Photoshop doesn't have bandpass or bandstop filters per se, but that doesn't meant we..."

Very nicely written, Sean.

Sean said...

Thank you Mike!

eos550d said...

I am a very new photoshop user, but I am not new to math :D. Is photoshop have a subtraction operation ? I mean if it does, then you only need one filter (say the high pass filter).

To get the lower filter you just subtract the highpass from the original. To get a bandstop you just need to subtract twice (subtract the high pass and the low pass) and to get the bandpass you just invert the bandtop :D.

Sean said...

@eos550d - As you may have read by now in the Mechanics post, a simple subtraction operation would work if we were using signed values for image data (that is, if we could have both positive and negative values). As we do not, we have to use workarounds. Still, the principle is the same - just not the ... wait for it ... mechanics :).

-