Make an Adaptive Histogram Equalization
Make an Adaptive Histogram Equalization
Hello,
I'm trying to convert this image :
to this image :
I read the page about Color Modification but i don't find the good args to apply. I would like to try the redist script from Fred's ImageMagick Scripts but i'm using the windows version of ImageMagick and I cannot install cygwin.
Does somebody knows the way to convert the first image to the second ? Or to use the redist script on windows ?
Best regards
I'm trying to convert this image :
to this image :
I read the page about Color Modification but i don't find the good args to apply. I would like to try the redist script from Fred's ImageMagick Scripts but i'm using the windows version of ImageMagick and I cannot install cygwin.
Does somebody knows the way to convert the first image to the second ? Or to use the redist script on windows ?
Best regards
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Make an Adaptive Histogram Equalization
This is quite close:
Instead of taking the average, you could blend.
Code: Select all
convert originalnew.jpg ( +clone -equalize ) -average o.jpg
snibgo's IM pages: im.snibgo.com
Re: Make an Adaptive Histogram Equalization
Thank a lot, it's working
Re: Make an Adaptive Histogram Equalization
I spoke too fast, with this image is do not work :
Original :
After convert originalnew.jpg ( +clone -equalize ) -average o.jpg :
The same image process with the software Color Factory of Fotoware, it's using the adaptive historgram equalization technique (very powerful) :
I'm trying to do the same image process with ImageMagick.
Original :
After convert originalnew.jpg ( +clone -equalize ) -average o.jpg :
The same image process with the software Color Factory of Fotoware, it's using the adaptive historgram equalization technique (very powerful) :
I'm trying to do the same image process with ImageMagick.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Make an Adaptive Histogram Equalization
What version of IM are you using. If old it may be equalizing differently for each channel. If new the default is to equalize the same for all channels.
If you are on a recent version of IM, you can try both
-equalize
or
-channel rgb -equalize
see if either give you a good result.
The only way to use my redist, is if you install Cygwin on Windows.
If you are on a recent version of IM, you can try both
-equalize
or
-channel rgb -equalize
see if either give you a good result.
The only way to use my redist, is if you install Cygwin on Windows.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Make an Adaptive Histogram Equalization
"Equalize" is an extreme effect that can benefit from other options. For example (in v6.8.5-7):
... seems a good result to me.
A huge number of histogram equalization effects are available using just ImageMagick. In addition, IM can generate a histogram for processing by an external program, to create a clut which is then applied to the image.
I use the external program technique for various processing, including what Wiki calls "contrast limited adaptive histogram equalization (CLAHE)", and various others including my current favourite, which involves finding the first and last peaks in the histogram, and increasing the contrast between the peaks at the expense of contrast outside the peaks. (Hence, the darkest tones will become darker, while the lightest tones will become lighter.)
Your sample result from Fotoware appears to do something similar: the dark doorway becomes very dark, while the middle tones of the right and middle walls have become spread further apart. This is very similar to the result from my script in this post, but slightly more extreme. So a blend instead of average would probably nail it.
Code: Select all
convert room.jpg ( +clone -channel RGB -equalize ) -average r.jpg
A huge number of histogram equalization effects are available using just ImageMagick. In addition, IM can generate a histogram for processing by an external program, to create a clut which is then applied to the image.
I use the external program technique for various processing, including what Wiki calls "contrast limited adaptive histogram equalization (CLAHE)", and various others including my current favourite, which involves finding the first and last peaks in the histogram, and increasing the contrast between the peaks at the expense of contrast outside the peaks. (Hence, the darkest tones will become darker, while the lightest tones will become lighter.)
Your sample result from Fotoware appears to do something similar: the dark doorway becomes very dark, while the middle tones of the right and middle walls have become spread further apart. This is very similar to the result from my script in this post, but slightly more extreme. So a blend instead of average would probably nail it.
snibgo's IM pages: im.snibgo.com
Re: Make an Adaptive Histogram Equalization
@fmw42
I'm using ImageMagick 6.8.5-4 2013-04-28 Q16
@snibgo
It's better thank to you. What is the software/process do you use to make the CLAHE process ?
I'm using ImageMagick 6.8.5-4 2013-04-28 Q16
@snibgo
It's better thank to you. What is the software/process do you use to make the CLAHE process ?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Make an Adaptive Histogram Equalization
Did you try my suggestion of testing
-equalize
or
-channel rgb -equalize
-equalize
or
-channel rgb -equalize
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Make an Adaptive Histogram Equalization
My own software. The contrast limiting is very simple: after reading the histogram, it can cap each value before calculating the cumulative. For the cap value, the code calculates the mean and standard deviation of the histogram counts. The user specifies a multiple of the standard deviation. The cap is the mean, plus this multiple times the StdDev.MathieuC wrote:What is the software/process do you use to make the CLAHE process ?
This comes after other process such as filling null counts. (A 14-bit camera can only generate 2^14 values, so a 16-bit histogram has counts in only about 1/4 of the values. The histogram is shaped like a comb, which confuses some processes. I fill in null counts by spreading non-zero counts.)
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Make an Adaptive Histogram Equalization
There is code available at http://tog.acm.org/resources/GraphicsGe ... iv/clahe.c if anyone wants to implement it. It is a reference in http://en.wikipedia.org/wiki/Adaptive_h ... ualization
Just curious if you redistributed the capped values on the histogram as described in the Wikipedia page?snibgo wrote:My own software. The contrast limiting is very simple: after reading the histogram, it can cap each value before calculating the cumulative. For the cap value, the code calculates the mean and standard deviation of the histogram counts. The user specifies a multiple of the standard deviation. The cap is the mean, plus this multiple times the StdDev.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Make an Adaptive Histogram Equalization
I didn't. I wasn't sure of the value of doing so. Redistributing seemed to be the equivalent of simply lowering the cap slightly. The magic (or the art) is in selecting the best cap value.fmw42 wrote:Just curious if you redistributed the capped values on the histogram as described in the Wikipedia page?
But I could be wrong about redistribution; when I get some time, I intend to experiment.
snibgo's IM pages: im.snibgo.com
Re: Make an Adaptive Histogram Equalization
Does someone knows a software who implements the CLAHE process (freeware/shareware) and who can be call with a DOS command line ?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Make an Adaptive Histogram Equalization
Not DOS, but you can download CLAHE plugin for ImageJ for all platformsMathieuC wrote:Does someone knows a software who implements the CLAHE process (freeware/shareware) and who can be call with a DOS command line ?
see
http://rsb.info.nih.gov/ij/plugins/clahe/index.html
http://rsb.info.nih.gov/ij/download.html
It is also in OpenCV library,
see
http://opencv.org/
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Make an Adaptive Histogram Equalization
If you are playing with adaptive histogram equalisation, you might look into the strongly related technique of pseudo-HDR. (HDR = High Dynamic Range.)
Here's a quick and easy pseudo-HDR. Windows script, but fairly easily translatable. It merges two equalised images: the darkest 30% and lightest 70%. (Adjust the boundary, CUTPC, as desired.) The mask used for the blend is a heavily blurred version of the original, which thus replicates the Adaptive effect of Adaptive Histogram Equalisation.
This script doesn't limit the contrast introduced by equalisation, so noise in areas of fairly constant tone becomes exagerated.
Here's a quick and easy pseudo-HDR. Windows script, but fairly easily translatable. It merges two equalised images: the darkest 30% and lightest 70%. (Adjust the boundary, CUTPC, as desired.) The mask used for the blend is a heavily blurred version of the original, which thus replicates the Adaptive effect of Adaptive Histogram Equalisation.
This script doesn't limit the contrast introduced by equalisation, so noise in areas of fairly constant tone becomes exagerated.
Code: Select all
set SRC=sm.jpg
set CUTPC=30
FOR /F "usebackq" %%L IN (`%IM%identify -format "WW=%%w\nHH=%%h" %SRC%`) DO set %%L
"convert" %SRC% ^
-alpha off ^
-colorspace HSL -channel B ^
-equalize ^
-colorspace sRGB -channel RGB,sync ^
( -clone 0 -level 0%%,%CUTPC%%% ) ^
( -clone 0 -level %CUTPC%%%,100%% ) ^
( -clone 0 -resize 2%%x2%% -resize "%WW%x%HH%^!" ) ^
-delete 0 ^
-compose Over -composite ^
pseudo.jpg
snibgo's IM pages: im.snibgo.com
Re: Make an Adaptive Histogram Equalization
Thank you for your help, the results is better than -equalize.