RetouchPRO

Go Back   RetouchPRO > Technique > Photo Retouching
Register Blogs FAQ Site Nav Search Today's Posts Mark Forums Read


Photo Retouching "Improving" photos, post-production, correction, etc.

Frequency separation math

Reply
 
Thread Tools
  #1  
Old 09-14-2014, 04:51 PM
nemrob nemrob is offline
Junior Member
 
Join Date: Sep 2014
Posts: 14
Frequency separation math

Hello to everyone, I'm new to this forum. I use freq. separation for a while now, and I've done quite a lot of research on the subject, but I could not find one article that thoroughly explains (for non-math buffs) how FS works. I would like to understand why it happens as it does, but I'm quite stupid for mathematics... I've read many forum posts with dropped bits of info here and there, but I can't seem to get the big picture: why do I use subtract in 8 bit and add in 16? What are the offset and scale settings? Normal waves have negative values, and I have to scale this to only positive ones (waves in images have no negative values - nothing can be darker than black), so I suppose I do just that, but I would like to know how exactly the separation and the apply image works. I've read somewhere that an 8-bit image has no exact 50% (that's ok), but the 16 bit have - how? 65,536 is an even number, as 256, so it can't have an EXACT midpoint, it just approximates better. Am I right?

Can anyone shed some light on this for me, please? It would be a great help. I can use the method without knowing any math, but somehow I just want to understand it deeper, now I feel like having someone elses clothes on, I just use it, but it isn't mine... Thank you very much for your help.

BTW, could anyone link an action that can separate an image into any number of splits? I remember seeing one somewhere, but I just lost track of it and couldn't find it later. Thank you.
Reply With Quote top
  #2  
Old 09-14-2014, 06:47 PM
skoobey skoobey is offline
Senior Member
 
Join Date: Jan 2012
Posts: 1,376
Re: Frequency separation math

It has to do with the fact that it isn't separating anythng, just making multiple copies of the same thing and applying different calculations to them. In all honesty, I have no ideas what those numbers mean within the apply image? Klev?

But what "separation" does is:

You make two duplicates of the inital layer, one is hte blur, and one is the inverted blur.

Holly ****? Inverted blur?

Well, yes, if you were to invert the blurred layer and set it to 50% opacity (hence the 2 number in the scale of the apply image, as the 1 would make it it's original luminosity, and we want 50% aka split by 2 I guess), you would get the top layer or the "high".

So, inverted blur set to 50 percent gives you the high pass. This works by the following principle: Inversion makes the inverted picture- complete opposite. 50% of a complete opposite is a neutral-neutral gray. We want to offset that by blur. So, blur it. But, as it is inverted, it reveals the opposite of the blur.

Making a stamp of it and blending to linear light will give you sharpening effect. And this goes for every other modification, median... and all other blurs.

Now, as for the low layer, it's a simple blur.

But what if we want a multiple frequencies?

It is possible, and very annoying to work with. Just repeat the process on the top, or the bottom layer. So, another blur and another sharpen. Notice, by every additional blur, you're gaining one layer, not two, as the blur is always on one of the already existing layers, and the opposite of the blur just adds on top of the stack, or in the middle. Only rule is that the layer set to NORMAL is on the bottom of the pile.

Last edited by skoobey; 09-14-2014 at 06:58 PM.
Reply With Quote top
  #3  
Old 09-15-2014, 01:56 PM
nemrob nemrob is offline
Junior Member
 
Join Date: Sep 2014
Posts: 14
Re: Frequency separation math

Okay, thank you for the answer.
I knew the inverted blur, I saw it in one of Calvin Hollywoods tuts, he called it (or something very similar) haut abpudern (~face powdering).
I'll try the multisplit method you wrote about.

Still I would like to know more about the math. I would be grateful is someone could explain it to me.
Reply With Quote top
  #4  
Old 09-15-2014, 02:45 PM
redcrown redcrown is offline
Member
 
Join Date: Jan 2006
Posts: 87
Re: Frequency separation math

You might find your answer here: http://www.modelmayhem.com/po.php?thread_id=439098

That's a forum thread that has been running for over 5 years and has thousands of posts. I believe the OP is the inventor of frequency separation.
Reply With Quote top
  #5  
Old 09-15-2014, 02:51 PM
mistermonday's Avatar
mistermonday mistermonday is offline
Moderator
Patron
 
Join Date: Dec 2005
Posts: 3,028
Re: Frequency separation math

OK Rob, I will try to help you out. before I explain the FS with the Apply Image command, let me give you a little background on separation and two filters in PS.
The Gaussian Blur filter locates the edges in an image and it reduces the contrast along the edge by mixing the two colors on both sides of the edge. The effect is a blurred edge for a certain number of pixels on each side of the edge and the blurring / reduced contrast is not linear, nor is the algorithm that generates the pixel values.
A Filter>Other>High Pass in PS has the opposite effect. The colors along an edge are increased in contrast / intensified and the effect is one of sharpening.
There is a special relationship between the two filters. Original = GB + HP. If you mathematically add together a Gauusian Blur and a High Pass, made at the same radius R, you will restore the original. You can try this in PS by taking any image, duplicate the background two times, apply a GB to the 1st copy, apply an HP filter to the top copy, change the blend mode of the top copy to Linear Light and reduce the opacity of that top layer to 50%. Form a new layer group of the GB and HP layer and toggle it on and off and the two views should look identical or almost identical to you. The reason you used Linear Light blend mode and 50% opacity is because PS does not have a stand alone blend mode called Add. However, the math is such that Linear Light at 50% opacity exactly performs the Add function mathematically. The GB and HP filters were pretty well how FS was accomplished for many years. So why do see everyone using the Apply Image command?
The reason is that the High Pass filter in PS is not very accurate. The HP error can be 2760/32,767. Where you will notice a difference visually is in the bright highlights (whites of eyes) or dark shadows with will be flatter looking.
The Apply Image command reduces the error in an 8 bit image to 115/32767 and in a 16 bit image to 1/32767, and visually you can not tell the difference when you toggle between the Split group and the original.
Using the Apply Image command, you are generating the HP layer by rearranging the formula above to HP = Orig - GB. The Apply Image command uses the 2nd copy of the bg as the Orig, it uses the 1st copy with the GB as the GB. Te mode used for an 8 bit image is Subtract. The offset is a short cut convenience. The 2 means the resulting HP is divided by 2. This saves you from having to change the opacity of the HF layer to 50%. Instead you leave it at 100% because the Apply Image reduced it for you.
Why do you use Add and 0 offset for 16 bit? Because 8 bit arithmetic is unsigned where as 16 bit is signed (a sign bit and 15 digits). You don't use a scale because it's already scaled by 1/2.
There is an action that will perform the split on both 8 and 16 bit images allowing you to input whatever R you like. I am away from my main Desktop PC but will post a link later tonight.
Cheers, Murray
Reply With Quote top
  #6  
Old 09-15-2014, 11:42 PM
klev klev is offline
Senior Member
 
Join Date: Jun 2010
Posts: 1,109
Re: Frequency separation math

Quote:
Originally Posted by skoobey View Post
It has to do with the fact that it isn't separating anythng, just making multiple copies of the same thing and applying different calculations to them. In all honesty, I have no ideas what those numbers mean within the apply image? Klev?
MisterMonday already explained it. My explanation would have been in the form of a factorization. One of them applies a gaussian blur subtracted or added or whatever. You essentially end up with an additive inverse function to that transform. I've been reading up on gaussian blur and its associated algorithm. I know what it does, but I haven't bothered to read up as much on its derivation prior to this. Wiki had a decent reference link on the topic. Apart from that I don't really like the way photoshop applies it. If the adjustment was applied on a gamma 1.0 space, you would have some amount of color mixing along blurred edges rather than that dark reverse ringing crap. Take a look if you don't mind ruining it for yourself. It's one of those things that you can never un-see.

As for splitting an image into multiple frequency ranges, you could start with one, then replace either the high or low with a split of that. I know there are several variations of iterative methods that do just that. It's mostly used for edge finding or sharpening though. A big issue with edge finding is the cleanup of noise and a lack of ringing, which appears when an algorithm over-corrects and inverts values along an edge.

Lastly to answer one question from the last thread on this, the reason you have trouble painting on a low pass layer is that you can steepen the difference between pixels. I was tempted to call it a gradient, but I'm not sure the term applies well here.
Reply With Quote top
  #7  
Old 09-15-2014, 11:57 PM
Aladdin's Avatar
Aladdin Aladdin is offline
Senior Member
 
Join Date: Jul 2008
Location: NJ/NY
Posts: 444
Re: Frequency separation math

Thanks Murray a bunch! Really great and yet very simple to understand walk through.
Reply With Quote top
  #8  
Old 09-16-2014, 02:30 AM
klev klev is offline
Senior Member
 
Join Date: Jun 2010
Posts: 1,109
Re: Frequency separation math

Quote:
Originally Posted by mistermonday View Post
Why do you use Add and 0 offset for 16 bit? Because 8 bit arithmetic is unsigned where as 16 bit is signed (a sign bit and 15 digits). You don't use a scale because it's already scaled by 1/2.
There is an action that will perform the split on both 8 and 16 bit images allowing you to input whatever R you like. I am away from my main Desktop PC but will post a link later tonight.
Cheers, Murray
I forgot to ask earlier, where did you find this information regarding photoshop's method of encoding? I ask because 16 bits can be signed or unsigned. They could define it however they like. Anyway assuming a sign bit, they presumably use a 2's complement encoding. That would give you a range of -(2^15) to (2^15)-1. They must reserve a bit somewhere for some other purpose if it is as you claim. I've seen others state that numbers around 32000 values as well, but I can't seem to verify them.
Reply With Quote top
  #9  
Old 09-16-2014, 04:36 AM
nemrob nemrob is offline
Junior Member
 
Join Date: Sep 2014
Posts: 14
Re: Frequency separation math

Thank you very much for the explanation. I get almost all, only a few bits still remain in shadow. Please bear with me, I'm not a math user
Really...

Quote:
Originally Posted by mistermonday View Post
...
The reason is that the High Pass filter in PS is not very accurate. The HP error can be 2760/32,767. Where you will notice a difference visually is in the bright highlights (whites of eyes) or dark shadows with will be flatter looking.
Can you tell me, how to obtain, measure the error level (2760/32,767) calculating or measuring the result? Same question for the 8bit error level (115/32767). Somewhere in a forum I've read 1/256. How you can obtain those results?

Quote:
Originally Posted by mistermonday View Post
...
Why do you use Add and 0 offset for 16 bit? Because 8 bit arithmetic is unsigned where as 16 bit is signed (a sign bit and 15 digits). You don't use a scale because it's already scaled by 1/2.
That is where you lost me. Is there any hope getting this without a BA in mathemathics?

Thank you for the action in advance.

Thank you and for the others for your comments.
Reply With Quote top
  #10  
Old 09-16-2014, 09:58 AM
mistermonday's Avatar
mistermonday mistermonday is offline
Moderator
Patron
 
Join Date: Dec 2005
Posts: 3,028
Re: Frequency separation math

Quote:
Originally Posted by nemrob View Post
Thank you very much for the explanation. I get almost all, only a few bits still remain in shadow. Please bear with me, I'm not a math user
Really...



Can you tell me, how to obtain, measure the error level (2760/32,767) calculating or measuring the result? Same question for the 8bit error level (115/32767). Somewhere in a forum I've read 1/256. How you can obtain those results?



That is where you lost me. Is there any hope getting this without a BA in mathemathics?

Thank you for the action in advance.

Thank you and for the others for your comments.
Rob, 115/32767 is the same as 1.23/256. You can get into minutia of the math but you don't need to waste your time to appreciate the approx error and the fact that everything Photoshop does has an underlying set of math algorithms and calculations going on.
As for the difference between the 8 and 16 bit splits, sorry I was not very clear. In 8 bit, you use subtract mode. The offset is 128 which means that the baseline is set to 128 which is gray and the results of the subtractions are added or subtracted (offset) from the gray point. You need to remember that in a High Pass filter, the edge colors are contrast-enhanced and everything else on the layer is set to the 50% gray point (128/256).
For the 16 bit image, you use the Add mode but you check the Invert box. This is the same as saying A + (-B) which is the same a subtracting. You still use a scale of 2 to divide the result by 2 which saves you the trouble of reducing the opacity of the HP layer to 50%. The offset is 0 because the 16 bit division is signed. The sign bit (1) + 15 bits (32767) Think of the base 0 being the mid point between -32767 and +32767 which in 8 bit is the 128 point.
Here is a link to an FS action I referenced above. You just need to start with a single layer, then start the action. It will duplicate the layers for you. A dialog box will appear allowing you to select the Radius of the blur and see the preview. Once you click ok the action will complete the separation and put place the result in a Layer Group.

http://www.mediafire.com/download/wn...nd_16_bit_.atn

Cheers, Murray

Last edited by mistermonday; 09-16-2014 at 10:10 AM.
Reply With Quote top
Reply

  RetouchPRO > Technique > Photo Retouching


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Frequency separation: Really non-destructive? baryon Photo Retouching 27 10-09-2013 05:19 PM
question about frequency separation method Caravaggio Photo Retouching 12 07-17-2013 12:21 AM
Skin retouching better than frequency separation gwlaw99 Photo Retouching 6 12-16-2012 03:34 AM
"asymmetric" frequency separation? drode Photo Retouching 12 12-25-2011 02:55 AM
Extended frequency separation fraiseap Photo Retouching 16 12-31-2010 01:33 PM


All times are GMT -6. The time now is 03:56 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
Copyright © 2016 Doug Nelson. All Rights Reserved