How to improve a picture with severely underexposed areas?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
bio

How to improve a picture with severely underexposed areas?

Post by bio »

Dear IM users,
I desire to improve the quality of a serie of picture taken with a digital camera.
All the pictures presents severely underexposed areas in the bottom due to a strong backlighting.
I tried adjusting with Photoshop CS and the result was satisfactory; in particular I used the Shadow/Highlight, using these settings for Shadow: amount 50%, tonal width 50%.

"Bad" original:

Image


"Better" modified with Photoshop Highlight/Shadows function; now in the bottom area you can see more details, the sky instead is unchanged.

Image

Since the photos are taken every 5 minutes and uploaded to my web site as webcam "live" view, I need to repeat this operation every 5 minutes. So I need to use IM to do this picture enanchement.

My question: is there a function or a procedure in IM wich can do a job similar to Photoshop CS Shadows/Highlight function?

Thanks in advance

Marco
Catman

Re: How to improve a picture with severely underexposed areas?

Post by Catman »

Hi,

I see this is an old question, but I have the same problem: I am working on a simple photo enhancer tool, and I would need to achive something similar with ImageMagikc (actually JMagick) like with Photoshop's Shadow/Hightlight tool. Do you have any suggestion how to do it?
Catman

Re: How to improve a picture with severely underexposed areas?

Post by Catman »

Actually, I have found an interesting tutorial (unfortunately it's not for ImageMagick): http://www.ncplus.net/~birchbay/3tone/3tone.htm

Is it possible to do the same with ImageMagick?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to improve a picture with severely underexposed areas?

Post by fmw42 »

For some non-masking techniques, you may want to look at my scripts, redist and retinex at http://www.fmwconcepts.com/imagemagick/index.html. They are not quick, especially retinex, but can be effective. Someone could speed them up by either converting to IM functions or at least recoding with one of the IM APIs.

Here are 2 tests results from each method.

Your original image trimmed to remove the top and bottom text.
http://www.fmwconcepts.com/misc_tests/r ... m3_sub.jpg

REDIST 1:
redist -m RGB 60,60,60 cam3_sub.jpg cam3_sub_redist_rgb_60_60_60.jpg
http://www.fmwconcepts.com/misc_tests/r ... _60_60.jpg

REDIST 2:
redist -m RGB 60,90,90 cam3_sub.jpg cam3_sub_redist_rgb_60_90_90.jpg
http://www.fmwconcepts.com/misc_tests/r ... _90_90.jpg

RETINEX 1:
retinex -m RGB -f 0 cam3_sub.jpg cam3_sub_rtx_rgb_f0.jpg
http://www.fmwconcepts.com/misc_tests/r ... rgb_f0.jpg

RETINEX 2:
retinex -m RGB -f 50 cam3_sub.jpg cam3_sub_rtx_rgb_f50.jpg
http://www.fmwconcepts.com/misc_tests/r ... gb_f50.jpg
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to improve a picture with severely underexposed areas?

Post by anthony »

The other solution is to create a grey scale mask of your image, whcih you then threshold to divide the image into bright and dark areas. You now adjust two copys of the image appropriatally and merge them using that thresholded mask. That is a 3 image composition.

The threshold hold does not need to be sharp, but could be a 'fuzzy threshold' which you can create using a strong -sigmoidal-contrast operator instead of -threshold. The mask will have a greys for pixels that are border line between the bright and dark areas, and thus get a partial modification from the two modified images.

If I can get a small but very distinct example image(s) to play with, I'll see about putting an example of this in Photo Handling in IM Examples
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Catman

Re: How to improve a picture with severely underexposed areas?

Post by Catman »

Thank you for your reply! I like anthony's idea, I will try to implement it using jmagick...
baibaichen
Posts: 11
Joined: 2010-03-23T20:32:14-07:00
Authentication code: 8675308

Re: How to improve a picture with severely underexposed area

Post by baibaichen »

anthony wrote: If I can get a small but very distinct example image(s) to play with, I'll see about putting an example of this in Photo Handling in IM Examples
hi anthony
could you try left part of this image "http://www.naturescapes.net/062004/Figure1.jpg" to show how to use sigmoidal-contrast for adjusting shadow/highlight.

By the way , I used Fred's balance script with parameter(25,0,0) for this image, the effect is not good.

Thanks
Chang
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to improve a picture with severely underexposed area

Post by fmw42 »

try my redist script

redist cam3_s.jpg cam3_s_redist.jpg
or
redist 50,70,70 cam3_s.jpg cam3_s_redist_50_70_70.jpg

or balance script with the following arguments

balance 20,20,0 cam3_s.jpg cam3_s_balance_20_20_0.jpg

or my script, autolevel

autolevel -m 0.6 cam3_s.jpg cam3_s_al_0p6.jpg
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to improve a picture with severely underexposed area

Post by anthony »

baibaichen wrote:hi anthony
could you try left part of this image "http://www.naturescapes.net/062004/Figure1.jpg" to show how to use sigmoidal-contrast for adjusting shadow/highlight.
Image link is broken!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to improve a picture with severely underexposed area

Post by fmw42 »

NOTE: the pictures used to create http://www.naturescapes.net/062004/Figure1.jpg were probably HDRI so had more dynamic range to get a better corrected picture than the low quality versions that were actually in this figure.

original:
Image

redist 50,50,40 Figure1L.jpg Figure1L_redist_50_50_40.jpg
Image

Here is the result of an autobalance script that I am working on

autobalance -t shadows -m 0.4 -s 2 Figure1L.jpg Figure1L_autobalance_shadows_b0_m0p4_l255_s2.jpg
Image



convert cam3_s.jpg -resize 50% cam3_s2.jpg
Image

redist 50,70,70 cam3_s2.jpg cam3_s2_redist_50_70_70.jpg
Image

autobalance -t both -m 0.4 cam3.jpg cam3_s2_autobalance_both_b20_m0p4_s2.jpg
Image
Last edited by fmw42 on 2010-05-16T22:56:23-07:00, edited 2 times in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to improve a picture with severely underexposed area

Post by fmw42 »

I have just posted a new script, duotonemap, to simulate Photoshops Shadows/Highlights function, with some improvements. see link below

(also similar to http://www.ncplus.net/~birchbay/3tone/3tone.htm, except 2tones rather than 3)
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to improve a picture with severely underexposed area

Post by anthony »

Also of interest is these two 'Fake HDRI' references.

http://www.nill.cz/index.php?set=tu1

http://jtrujillo.net/qpix/

This is after all what HDRI was originally invented for, though really HDRI was not needed to produce such results.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to improve a picture with severely underexposed area

Post by fmw42 »

bio wrote:Dear IM users,
I desire to improve the quality of a serie of picture taken with a digital camera.
All the pictures presents severely underexposed areas in the bottom due to a strong backlighting.
I tried adjusting with Photoshop CS and the result was satisfactory; in particular I used the Shadow/Highlight, using these settings for Shadow: amount 50%, tonal width 50%.

My question: is there a function or a procedure in IM wich can do a job similar to Photoshop CS Shadows/Highlight function?
I just created a new script, shadowhighlight, at the link below, to emulate the Photoshop function of the same name.
Post Reply