Frequency separation is considered one of the most sophisticated and difficult techniques in image postproduction, but strangely enough it is considered almost exclusively in relation to skin retouching in portraiture.
Just as frequently it is a technique used badly and in an approximate way with often questionable results, to be polite. So I decided to make a series of posts about it, to clarify what it is, what it is for and above all how the separation of frequencies should be done, if not at least a little better. Also at the end of the series of posts I'll explain how to separate multiple frequencies and why: that is, I'll explain how to make and use a real "equalizer".
First of all what are we talking about? The term "frequency" refers to the greater (or lesser) speed with which any oscillating phenomenon changes state over time: a person who repeatedly gets up and sits down and then gets up and sits down again, and so on is an example pretty typical - if a little silly. If he repeats the gesture 5 rather than 10 times a minute (or 100, or whatever times) it means that he does it more frequently or "with a higher frequency". But a photograph is the most still thing in the world, so what are we talking about? By analogy we are talking about those quantities whose variation occurs more or less frequently in the space of photography. So let's talk about spatial frequencies (even if the term is a bit improper, but it has come into use in this sense), even if it would perhaps be more appropriate to refer to "spatial gradients".
In the post-production of images, the fact of being able to work only on that part of the photograph whose variations are rapid or vice versa slow would naturally be a great advantage. Removing a mole or skin pores involves working on what we have agreed to call high frequencies, while changing the overall color tone of a complexion involves working on low frequencies instead.
Yeah but how high (or low)? You should understand that in the case of digital images the natural unit of measurement is the pixel [1]. Two particulars (ie different tones) one pixel away are - to understand each other and a little approximately - the minimum visible detail (in reality it is not visible at all unless you zoom in exaggeratedly) in a given image. So from now on I will assume the number of pixels (or if you want a radius in pixels, since the image is two-dimensional) as a reference unit: the frequencies below 10 pixels for example represent details or structures of enough detail, while for example the variations over the arc of 100 pixels represent quite slow or, if you prefer, low frequencies.
Naturally this refers to the total pixel dimensions of the image: one thing is 10 pixels on a 5000 pixel image, another would be the same 10 pixels on a 100 pixel image.
Just to give you an indication of where I would like to go, one of the best-known applications of the unsharp mask technique (or unsharp mask in English) is to use a rather high radius (30 or 50 pixels) and a contained intensity in order to increase the local contrast - and not the apparent sharpness, so you should use very small rays and high intensities. Somehow this technique also falls within the logic of frequency separation.
In general it remains true that high (spatial) frequencies correspond to smaller radii (in pixels), low frequencies to greater radii. And already here I invite you to take a break because it is easy to get confused.
Now I have to convince you of another complication, but I swear it's the last one: in Photoshop (or in another software) we have a method to isolate in one layer only that part of the image which refers to the high frequencies (ie in the strange terminology we are using to tonal variations that occur on the scale of a few pixels)?
It should be quite intuitive to convince yourself that (almost) every blur filter is a filter that selects low frequencies precisely because it cancels out the finer details. The problem therefore is not to isolate the low frequencies (and therefore by attraction, we will see, the high ones), but how well different filters act in obtaining the result.
If I blur all the details within a radius of 5 pixels (or 10, or any other number) I have naturally filtered, i.e. separated, the longer frequencies. And then, as many already know, it will be possible to build two copy levels of the starting image: in the one below one proceeds with a blurring with a certain radius in pixels, in the other the details must remain and this will be obtained by applying the one below to this level with blending mode "subtract" of course. We want the subtraction to occur at the maximum level, so we choose the maximum possible scale (i.e. 2) and we choose an offset (i.e. a reference value) of 128 so that on the high frequency layer mid-grey appears where no details are present.
Above you will find on the left the original image with all the details, in the center the blurred image (low frequencies) and on the right the details (high frequencies). In this case I used a 10 point Gaussian blur. Since the layers thus constructed are stacked in order from left to right from bottom to top, you will only see the right image, since the 3 layers are in "normal" blend mode. If you now choose the "linear light" blending mode for the high-frequency level (the upper one) you will see the original photo reappear because the chosen blending mode is transparent where the layer is medium gray (i.e. where there are no details, this is the which is why we chose medium gray as the offset), while adding detail back where it is on the underlying layer (the blurred one) which contains only the color variations. The fact that it is "transparent" at 50% average gray is a common fact for all blending modes of the same group of "linear light" ("Overlay", "Soft Light", "Hard Light", "Bright Light" , "Line Light" and "Point Light")
This is the essence of frequency separation: making a pair of layers with one containing the slow color shifts overlaid with another containing the detail. This - however quickly explained - is the method of frequency separation as it is used today. It's time - before discussing how to possibly go further, to make various clarifications and give some clarifications.
If between the two levels thus constructed I insert a third transparent one, I can (gently) use a brush to distribute a slightly different color tone: this is normally done with a brush with a not very small radius and quite soft, with opacity around 10 % so as not to perceive sudden color variations. The overlying high-frequency layer (which remains unmodified) will automatically re-enter the modified color detail. Alternatively we can erase details (for example pores or moles) simply by painting with medium gray on the high frequency level.
Now several questions: I have chosen in this procedure a Gaussian blur of radius 10 points. Why Gaussian and why ten points? I'll come back to the choice of Gaussian blur in a moment. The 10 points of the radius have been chosen so that the finer details disappear with the blur (in this photo) and only the less detailed part of the image remains. In another photo this number may be different.
But it is clear that with this choice, for example, the shape of the nostrils (or of the teeth) are "details" largely remained even on the low frequency level and therefore I will not be able to proceed (when I wanted to) for example to erase the teeth with the procedure that I just described to you: the most I could be able to erase are finer details of the teeth, grooves or cavities for example that appear on the high frequency level. As if to say that the choice of a radius of 10 points is largely arbitrary and relative to the use we want to make of it: if we want to give (or remove) color to the model's cheeks, for example, it is a convenient choice. But if it had been a sky with clouds I could not have painted those clouds with the blue of the sky because the structural details of the clouds would have been reinserted above that blue, with a clearly false effect.
Original image with enhanced contrast to make clouds very visible
Low-frequency layer
High-frequency layer
What you get if you try to paint over the clouds at low frequencies: as you can see the blue overlay maintains the detail structure of the cloud because it is done at a pixel scale larger than 10 points, around 100-200. Below the same operation done on a blurry image with radius 200 pixels, done rather quickly just to show the difference.
Therefore, before going further (multi-frequency separation, in particular) it is good to discuss some details a little better. The older ones (photographically speaking) will remember that at the dawn of digital photography we proceeded in a slightly different way than what I have shown you.
In particular, Adobe supplies a filter to select the high frequencies which in the English version is correctly called high-pass filter while in the Italian one for incomprehensible reasons it is translated into "Accentuate passage". So an alternative way to proceed was (and is sometimes still taught) to build two copies of the original photo, to act on the upper copy with this high-pass filter (that is, which only lets the high frequencies pass, or accentuates the passage) and on the copy lower with the Gaussian blur having the only precaution of using exactly the same radius in both passes. In this old procedure, we still chose "linear light" as the blending mode for the top or high-frequency layer, but reduced its opacity to 50%. Apparently again we got the original image.
So why one or the other process? Because of course using two different methods does not necessarily lead us to the result of separating the high frequencies from the low ones with the same precision, which is instead essential for the work we want to do. There is a very simple way to understand which of the two methods is actually better: since apparently in both cases we have obtained the starting image again, the simplest thing to do is to compare the image at separate frequencies with that of departure. This procedure is actually a bit like crushing a peanut with a mallet, as you will see: if something is not seen it is (almost) as if it weren't there, unless you repeat the procedure many (too many) times.
In both cases, after having obtained the two layers with separate frequencies, we proceed to duplicate the starting image once again, to move this layer above all and to set the blending method to difference. If everything is right it should of course result in a totally black image because if the frequency separation had produced exactly the original image, then by subtracting it from the original we should obtain perfect black. Already on sight we discover that it is not exactly like this but looking at the statistics that appear under the histogram we see that with the second procedure - the "ancient" one which used "enhance passage" - an average value appears under the histogram which is not zero, but of 0.30 (with standard deviation of 0.70) [2].
Already on sight the above image obtained by subtracting the "old style" frequency separation from the original is not perfect, if you look carefully.
With the first procedure - the "modern" one if you like - instead we obtain an average of 0.66 with a standard deviation of 0.66; naturally if we remove the two levels with separate frequencies we obtain the comparison between two identical images (which naturally corresponds to mean 0 with standard deviation 0). What do these numbers tell us? That the difference between the original and the split-frequency image corresponds to something that is effectively almost black, differing from black by on average less than 1 part (out of 255 of course), but in the case of the old procedure there is some point where the difference is greater (because the standard deviation is greater). And this is somewhat visible.
There was actually also a third way of proceeding (which involved the same procedure with the accentuate passage filter, but choosing the "Overlay" blending mode at 100% opacity), but it gave results significantly worst [3] [4].
What remains to be figured out is (1) why the frequency separation isn't perfect and (2) if there is any way to fix this. This is necessary before proceeding to more complicated separations because if we carry significant errors with us, these can only be amplified if we look for more complex procedures.
The point to understand is, as I said, that each blur filter somehow selects the lowest frequencies, but the way - or if you prefer the quality - of this separation can be different.
Below you see a graphical representation of how intense the different frequencies are in an image when the median (left), original (middle), and (right) blur filter was used when blur is used instead Gaussian. I must point out that you are unable to reconstruct these representations because they were obtained with different software. Nor do I think you are interested in the details of mathematics: what you can clearly see, however, in the image on the right in particular is that two stripes (one horizontal and one vertical) are significantly lightened, thereby representing that the corresponding spatial frequencies are less intense. But (1) not even in the case of the Gaussian filter do you find a white band and the rest more or less dark - which means that there is some smooth transition between high and low frequencies - and (2) what you get using blur filters different is drastically different.
From this you deduce that (1) it is not the same thing to attempt frequency separation with one blur filter rather than another and (2) for each filter that selects low frequencies for you you should find the appropriate "opposite filter" that vi selects what should remain in the high frequency level.
We have actually already solved point (2) with the "Apply image" procedure and the subtraction method: in the 'old' procedure we assumed - without thinking too much about it - that the high pass filter that Adobe supplies us was exactly the inverse of a Gaussian blur, which is not said. Indeed we can easily verify that this is not the case: as usual, we build two copy levels of the original image. On the upper one we apply the high pass filter that Adobe has inserted in Photoshop with the "Linear light" blending mode at 50% opacity. On the lower one we apply the usual Gaussian blur always remembering to use the same radius in pixels used for the high pass filter. Now let's proceed like this: we deactivate the layer on which the blur was made, leaving active only the original image and the layer on which the high-pass filter acted.
The resulting image - which corresponds to the "Linear Light" blended high-pass filter at 50% opacity on only the background containing the original image - very obviously corresponds to a version with a higher apparent sharpness. This was the original reason for the introduction of the high pass filter, to increase the apparent sharpness. We invert the layer with the high-pass filter - getting a blurry image as we expect - and select everything, copying the composite. on an even higher level. Now we deactivate the layer with the high pass filter, we put the difference blending mode on the top layer and we activate the layer again with the Gaussian blur. Apparently everything is black, but the numbers under the histogram warn us that the mean is 0, but the standard deviation is zero: this means that the two levels are not identical, even if the difference is very small.
So the high pass filter at 50% opacity in linear light and the Gaussian blur are almost the exact opposite of each other, but they're not exactly.
Now you may wonder why all this analysis: after all, the differences we have found are so small as to be practically not perceptible and all three procedures presented are virtually equivalent for the purpose of frequency separation. If something is not seen then it is not there (unless we amplify it).
Of course there is - for me at least - a matter of intellectual taste in understanding where the problem lies, but there is also a much more practical motivation. In fact, if our aim was, as it actually is, to iterate the procedure we have seen, increasing the radius used each time, to obtain a sequence of levels with different separate frequencies. in practice a real frequency equalizer like those used in audio management, then the risk is that these small errors that we carry with us eventually become too big and unmanageable.
The solution to this little enigma is actually quite simple and we have it under our eyes: the point is that - without telling you I admit it - I worked as is often done on 8 bits (you should have guessed it when I gave you the tone (128,128,128) as medium gray) and unfortunately half of 255 is not 128, but 127.5, i.e. a tone that does not exist in this representation. In 16 bits the "medium gray" (128, 128, 128) corresponds to 16448, not to 16384 which is instead the "true" medium gray, or at least a non-approximate value like the one we get at 8 bit color depth.
If you proceed as I showed you previously but after modifying the 16-bit image you will obtain - unlike in the previous case - a perfect frequency separation, i.e. the difference from the original image is actually perfect black. There is only one small difference to keep in mind compared to the procedure seen in the 8-bit case: when you proceed to "Apply image" of the layer with Gaussian blur on the one that will contain the details (i.e. the high frequencies) instead of choosing method merger "Subtract" we choose "Add", but clicking the choice "Invert" (adding the inverse is clearly the same as subtracting) leaving the scale at 2, but choosing offset at 0: this derives from the fact that Adobe has chosen ( probably to avoid too large numbers) to represent the 16 bit depth from -255 to +255, so the 0 tone effectively represents medium gray. The exact one this time.
Once this is done let's duplicate the background again, move it up and choose the "Subtract" blend method to compare the composite with the original image: this time we get mean 0 and standard deviation 0, confirming the reasoning done. Now the separation of the frequencies appears perfect [5], even if - I underline it again - the two levels are not so rigidly separated: some (little) detail remains on the level containing the low frequencies and some low frequencies remain very low in the level of the high frequencies.
Given these foundations, in the next post of this series we will see how to iterate the above procedure to build a real multi-frequency filter.
_______
[1] Note that the pixel is not a measure of distance, but somehow measures the dimensions of a photograph: a photo of 500 pixels in length contains less detail than a photo of the same subject shot at 5000 pixels. So somehow chosen the image we're talking about the number of pixels two points are apart gives us a good, if rather abstract, measure of distance. But I'll talk about this in another post, possibly.
[2] These numbers may be slightly different depending on the source image.
[3] If you notice the different blending modes, they are grouped into 6 different types that have more similar behaviors within them (normal, darken, lighten, contrast, invert/cancel and components). The members of the group that contains "Overlay" as the first method act on the contrast and are all transparent to medium gray, but have a more or less violent effect. This is why using one or the other uses different opacities.
[4] With this procedure and by repeating the comparison by subtraction with the original image, a significantly higher average value is obtained, around 2-3. I'm not an expert on the history of Photoshop, but I think the different blending modes were added a little at a time, so in the past one had to adapt to the methods Adobe provided at the time (or use more sophisticated software)
[5] Of course if we had followed the procedure that used the high-pass filter (or high-pass filter) as the opposite of the Gaussian blur the error would have remained: this confirms that "High-pass" and "Gaussian blur" are not the same opposite of the other
コメント