Approve the Cookies
This website uses cookies to improve your user experience. By using this site, you agree to our use of cookies. Read More.
OK
Index  •   • New posts  •   • RTAT  •   • 'Best of'  •   • Gallery  •   • Gear  •   • Reviews
New posts  •   • RTAT  •   • 'Best of'  •   • Gallery  •   • Gear  •   • Reviews
Register to forums    Log in

 
FORUMS Post Processing, Marketing & Presenting Photos HDR Creation
Thread started 02 Jan 2017 (Monday) 14:03
Prev/next
sponsored links
(this ad will go away when you log in as registered member)

Re-establishing local contrast in HDR images with Wavelet Decomposition - one method

 
kirkt
Cream of the Crop
5,333 posts
Joined Feb 2008
Philadelphia, PA USA
Post has been edited 9 months ago by kirkt.
Jan 02, 2017 14:03 |  #1

Hi folks,

When producing output from high dynamic range image data, one often fights the battle of tonal range compression and re-establishing global and local contrast. You want to pack all of that tonal information into the final image, but in doing so you must necessarily compress the tonal information at the expense of contrast. And contrast is what makes the image look terrific, just like you remembereed the scene and visualized it in your mind's eye.

There are many ways of going about (re)establishing contrast in your toned HDR data. Some applications will do it as part of the toning process, and do it very well. Some applications are better at the tonal compression, but apply heavy-handed local contrast algorithms that leave your image looking unnatural.

This balancing act can lead to adopting a workflow that ultlizes the HDR application to compress the tonal range into a flat looking result that contains all of the tonal data, but lacks contrast. There is nothing woung with this apporach! It often leads to more work, but gives the user more control over the final image. Thus, the source exposures are merged and toned in an HDR application and the flat result is brought into a pixel editor to deal with contrast and color for the final image.

Just like anything else, there are many ways to bring out and re-establish contrast. In this post, I will present a method which is not necessarily novel and does not use some newfangled tools, but is a slightly unorthodox use of a retouching method that is widely used to give retouchers control over various levels of detail in an image (think protrait retouching). This method uses Photoshop.

Many of you may be familiar with the concept called "frequency separation" or "wavelet decomposition." The idea is that the base image can be broken into a low-frequency part and a high-frequency part and the elements of the two parts can be manipulated independent of each other. The typical use is in portrait retouching where the high-frequency part of the image contrains skin blemishes and pores and the low-frequency part contains large areas of color and tone on the model's face. Cloning and healing of the high-frequency details does not touch the underlying color and tone and unifying the underlying low-frequency tone and color does not smooth over the details that make the skin look natural and with texture (versus the fake, plasticky look of over-smoothing).

Well, this concept is nice for HDR images that need local contrast boosted as well. You can decompose your flat image into levels of detail and then individually boost the detail in each level independently. Think of it as a graphic equalizer for your image detail. In fact, there are plug-ins and extensions for PS that do just that, including:

Topaz Detail: https://www.topazlabs.​com/detail (external link)

Fixel Labs Detailizer: http://aescripts.com/f​ixel-detailizer-ps/ (external link)

WOW! Frequency Equalizer: https://www.knowhowtra​nsfer.com .../wow-frequency-equalizer/ (external link)

These plug-ins/extensions are all good at what they do, but they present the user with simplistic controls that may or may not provide the control you need. And they cost money.

You can achieve the same kind of apporach to local contrast with a little creativity and some Googling. The idea is to find a way to perform frequency separation (wavelet decomposition) of your image and then adjust the contrast of the idividual frequency bands to your liking. Here's one method I came up with.

First, you need a way to separate your image into the various frequency bands. If you are unfamiliar with frequency separation or wavelet decomposition, give it a Google and watch the videos. The basic idea is that your base image gets blurred with a Gaussian Blur radius that gets rid of all of the detail that you want to treat separate from the underlying tone and color of the image - this blurred layer becomes the low-frequency, or "residual" component of the separation. You then subtract the blurred layer from the original image and the result is a mostly gray layer that contains all of the high-frequency detail that you blurred out of the original in the previous oepration. If you then set the blend mode of the high-frequency layer to "Linear Light" the blended result of the blurrred + high-freq Linear Light layer is the original image. Taa daah! Now you can heal and clone out high frequency blemishes, etc. without affecting the underlying tone and color, etc.

The linear light, high-frequency layer looks a lot like the kind of layer that gets generated when you perform a high-pass sharpening operation, or dodging and burning - that is, it is mostly middle gray, with deviations away from middle gray at areas of high contrast in the source image. This is terrific because when you use a contrast blend mode, like linear light, areas of contrast in the original image get amplified, while areas of middle gray in the layer do not affect the blend. This is precisely what we would like to do to re-establish local contrast: amplify areas of contrast in the original image without affecting large, flat areas of tone and color. With the frequency separation approach we can do it selectively, based on detail size (spatial frequency).

Okay- so we need a tool to do the frequency separation - and it would be nice if we could specify how may levels of frequency-based detail separation we want. Well, there is a script for that, and you can download it here:

https://github.com ...ster/waveletDecompo​se.jsx (external link)

You need to copy the code text from the above link and paste it into a new text document and name the document "<anything>.jsx" - for example, I call my file "WaveletDecomp.jsx". Place this file in your PS version's Scripts folder and restart PS - it will now be available in the Scripts menu. I did not write this script, so please read the GitHub documents on usage, etc. You can also open the script text in any text editor and read it to follow along with the author's intent.

Run the script and accept the default value of 5 wavelet detail scales - the script will create a duplicate of your original document and then make five layers of detail separation in the new document (it leaves your original image untouched). From my experimenting with the script and editing it, the size of the details in each layer is dependent upon the pixel dimension of your original image. You can experiment with all of these parameters to see what workflow is best for your images. If your original image file has only the background layer, you may get an error message when you run the script - "The command Copy Merged in not available" - just hit "OK" to dismiss the error and the script will continue on its merry way - this part of the script flattens your current document, which will not be possible if the document is already flat, hence the error.

Take a look at the five layers the script created in your new document - you will notice that the script creates each layer and sets its blend mode the "Linear Light". To visualize exactly what each layer looks like, select the five layers and change their blend modes to Normal. Now you can see the primaily gray with darker and lighter edge details in each of the layers. See how the scale of detail changes in each successive image?

Choose any one of the layers, maybe Scale 3, and make a new Levels adjustment layer above that layer. Clip the Levels adjustment layer to the Scale 3 layer and turn off all of the layers above the new Levels layer. Now you are viewing Scale 3 layer in Normal blend mode with a Levels adjustment layer that has not been changed, but will only affect Scale 3 layer when you edit the Levels. FYI - you clip the adjustment layer to the Scale 3 layer by hovering your mouse over the border between the layers and holding down the OPT or ALT key - your cursor icon will change to a double right angled arrow - click on the border between the layers and the Levels adjustment layer will now be indented in the layer stack and clipped to the Scale 3 layer, affecting onyl the Scale 3 layer and not every layer below the Levels adjustment.

With the Levels adjustment dialog window visible, drag the black and white points in equal amounts, say to 50 and 205 respectively. Note the change in the Scale 3 layer - middle gray stayed middle gray, but tones darker than middle gray got even darker and tones lighter than middle gray got even lighter. This is adding contrast to the Scale 3 layer via the Levels adjustment layer. Now switch all of the Scale layers back on and set their blend modes back to Linear Light and toggle the visibility of the new Levels adjustment on and off - see the effect it is having on the image? - it is adding local contrast to that Scale 3 level of detail in the image. Add clipped Levels adjustments to each Scale layer and change the Black and White points to add contrast (keep the midtone value at 1.00). Now you can adjust the amount of contrast for each scale layer by moving the Black and White points on the associated Levels adjustment layer - the more you move the black and white point toward middle gray, the more contrast you are adding and the more detail you are amplifying in that Scale layer. You can also fade the effect back as much as you want by adjusting the opacity of the Levels adjusmtment.

This is like having a graphic equalizer for different levels of detail in your image - the Levels adjustment is where you set the intesity and amount of contrast for each level of detail.

I have recorded an action in PS that runs the Wavelet Decomposition Script (you can change the amount of wavelet levels, but use the default of 5, because that is what the action expects) and then makes the Levels adjustment layers for all five levels and sets their intial black and white points to values that give fairly good, out-of-the-box results. The Action requires that the script be called "WaveletDecomp" (remember that you copied and pasted the script into a text file and named it something.jsx? Call it WaveletDecomp.jsx).

The action also adds a Levels adjustment layer at the top of the Wavelet group with a slight bump to the midtones (Gamma = 1.10) you can dial this back to 1.0 or diable the layer if you do not want the effect.

You can download the Action here:

https://db.tt/jpxMp8DH​gx (external link)

Just remember:

1) you need to copy-paste the script into a new text document and name the doc "WaveletDecomp.jsx"
2) you need to put this script in the PS scripts folder for the version of PS you are running (PSXX > Presets > Scripts) and restart PS for the script tp be available.
3) load the action into your version of PS - the easiest way to do this is to drop tha action file onto the PS icon in your Dock or Task Bar. You can also load the action from the Actions panel in PS.

Note that you may see banding appear in the new document - this is just spurious rendering artifacts in PS - if you zoom into the image to greater than 50%, the artifacts disappear.

In the next post I will give an example of the action some recommendations on usage.

Have fun!

Kirk


Kirk
---
images: http://kirkt.smugmug.c​omexternal link

LOG IN TO REPLY
sponsored links
(this ad will go away when you log in as registered member)
kirkt
THREAD ­ STARTER
Cream of the Crop
5,333 posts
Joined Feb 2008
Philadelphia, PA USA
Post has been edited 9 months ago by kirkt.
Jan 02, 2017 14:15 |  #2

Here is a basic example of the effect. This is not an HDR image, but is a contrasty image that I would like to add some pop back into the mix.

I just ran the Action and edited the black and white points on the Scale 5 levels adj. layer to be 30 and 225.

Top: Before
Bottom: After


Kirk

HOSTED PHOTO
please log in to view hosted photos in full size.

HOSTED PHOTO
please log in to view hosted photos in full size.

Kirk
---
images: http://kirkt.smugmug.c​omexternal link

LOG IN TO REPLY
kirkt
THREAD ­ STARTER
Cream of the Crop
5,333 posts
Joined Feb 2008
Philadelphia, PA USA
Jan 02, 2017 17:23 |  #3

Another example.

kirk

HOSTED PHOTO
please log in to view hosted photos in full size.

HOSTED PHOTO
please log in to view hosted photos in full size.

Kirk
---
images: http://kirkt.smugmug.c​omexternal link

LOG IN TO REPLY
kirkt
THREAD ­ STARTER
Cream of the Crop
5,333 posts
Joined Feb 2008
Philadelphia, PA USA
Jan 02, 2017 20:04 |  #4

Raw Therapee also has wavelet tools for contrast.

Kirk


Kirk
---
images: http://kirkt.smugmug.c​omexternal link

LOG IN TO REPLY
kirkt
THREAD ­ STARTER
Cream of the Crop
5,333 posts
Joined Feb 2008
Philadelphia, PA USA
Jan 03, 2017 14:57 |  #5

Here is another example - I modified the script to scale the increment between wavelets according to the long side of the original image. This way the steps between each detail level are somewhat normalized to the image size. The more detail levels you specify, the finer the increments are.

kirk

Here is the code snippet that I edited - follow along in the original code and you will see the differences:


function generateDocWavelets( waveletDoc, levelCount, addExtraControls ) {
waveletDoc.paste();
waveletDoc.activeLaye​r.name = "Original";

var original = waveletDoc.activeLayer​;
var docWidth = waveletDoc.width;
var docHeight = waveletDoc.height;
var longSide = 0.0;

if (docHeight > docWidth) {
longSide = docHeight;
} else {
longSide = docWidth;
}

var scale = longSide/200.0/levelCo​unt;

for ( var i = 0; i < levelCount; i++ ) {
var src = waveletDoc.activeLayer​;
var octave1 = original.duplicate()
octave1.move( src, ElementPlacement.PLACE​BEFORE );
//octave1.applyGauss​ianBlur( Math.pow( 2.0, i ) - 0.5 );
octave1.applyGaussia​nBlur( i * scale + 1 );
octave1.name = "Blurred " + String(i + 1);
var octave1_blr = octave1.duplicate();
octave1_blr.visible = false;
...

First image - original
Second image - contrast boost.

This was applied to a Canon 5DIII (5760 pixels long side) image - 100% crop.

NOTE: You will need to set your Units to PIXELS for this to work properly, or add some lines to the script to temporarily change the Units to Pixels.

kirk

HOSTED PHOTO
please log in to view hosted photos in full size.

HOSTED PHOTO
please log in to view hosted photos in full size.

Kirk
---
images: http://kirkt.smugmug.c​omexternal link

LOG IN TO REPLY
kirkt
THREAD ­ STARTER
Cream of the Crop
5,333 posts
Joined Feb 2008
Philadelphia, PA USA
Post has been edited 9 months ago by kirkt.
Jan 03, 2017 15:44 |  #6

Another example, from an HDR image set. 100% crop of a half-res 5DIV image.

kirk

HOSTED PHOTO
please log in to view hosted photos in full size.

HOSTED PHOTO
please log in to view hosted photos in full size.

Kirk
---
images: http://kirkt.smugmug.c​omexternal link

LOG IN TO REPLY
monty87
Senior Member
monty87's Avatar
266 posts
Joined Feb 2008
So Cal High Desert
Jan 03, 2017 17:14 |  #7

That's a great write up Kirk. I have been creating wavelet decomposition using frequency separation for 1,2,4,8,12 pixels and had created a set of actions for it. I will have to definitely try the script as it can run much faster. But I never tried running level adjustment on the the frequency layer. I guess once you have the frequencies separated the the possibilities are endless.

What I used wavelet mostly was to run noise reduction on 1px and 2px frequency layer. (Got the idea from using PixInsight). I would apply high noise reduction, (2 to 3 passes at times) on 1px layer, and moderate noise reduction if needed on the 2px layer. And at the same time apply sharpening on 4px layer.

Looking forward to try the script.

Again great post.


Monty - http://umang.photograp​hy/external link

LOG IN TO REPLY
Benitoite
Goldmember
Benitoite's Avatar
Joined Jan 2015
Morgan Hill, CA
Jan 03, 2017 17:41 |  #8

Nice. I do all my wavelet processing in the Rawtherapee app. Very powerful toolset available in that so-named tab.




LOG IN TO REPLY
kirkt
THREAD ­ STARTER
Cream of the Crop
5,333 posts
Joined Feb 2008
Philadelphia, PA USA
Jan 03, 2017 19:11 |  #9

Thanks - once you download the script, you can play with modifying it, etc. I have added a drop-down menu selection in the dialog to choose from different levels of Wavelet Interval spacing, from 1 (coarse) to 4 (fine). The choice is basically a scaling factor for the interval between successive wavelets.

Here is a 100% crop from a very high dynamic range scene - the default levels values (black = 50, white = 205) for each layer, with the wavelet group applied at 70% opacity.

kirk

HOSTED PHOTO
please log in to view hosted photos in full size.

HOSTED PHOTO
please log in to view hosted photos in full size.

Kirk
---
images: http://kirkt.smugmug.c​omexternal link

LOG IN TO REPLY
icor1031
Senior Member
Joined Jan 2015
Aug 09, 2017 01:31 |  #10

Need to clean your desk!


(2) Canon 6D || Zeiss Sonnar 135mm f/2 || Zeiss Otus 85mm f/1.4 || Sigma 85mm f/1.4 || Helios 44-2 58mm f/2 || Sigma 50mm f/1.4 Art || Canon 24mm f/2.8 || Rokinon 14mm f/2.8 || (2) Eg-S Focusing Screen
T3i || Elan 7n || Cotton Carrier || Streaklight 360 || i1display Pro || Colormunki Photo

LOG IN TO REPLY
sponsored links
(this ad will go away when you log in as registered member)

2,154 views & 6 likes for this thread
Re-establishing local contrast in HDR images with Wavelet Decomposition - one method
FORUMS Post Processing, Marketing & Presenting Photos HDR Creation


Not a member yet? Click here to register to the forums.
Registered members get all the features: search, following threads, own gear list and ratings, likes, more forums, private messaging, thread follow, notifications, own gallery, settings, view hosted photos, own reviews and more...


AAA

Send feedback to staff    •   Jump to forum...    •   Rules    •   Index    •   New posts    •   RTAT    •   'Best of'    •   Gallery    •   Gear    •   Reviews    •   Polls

COOKIES DISCLAIMER: This website uses cookies to improve your user experience. By using this site, you agree to our use of cookies. Privacy policy and cookie usage info.

POWERED BY AMASS 1.4version 1.4
made in Finland
by Pekka Saarinen
for photography-on-the.net
Spent 0.00087 for 4 database queries.
PAGE COMPLETED IN 0.03s
Latest registered member is Allyn
843 guests, 404 members online
Simultaneous users record so far is 6106, that happened on Jun 09, 2016