Invert LUT and Equilize Histogram

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
bhim.rathor
Posts: 21
Joined: 2016-02-21T13:47:15-07:00
Authentication code: 1151

Invert LUT and Equilize Histogram

Post by bhim.rathor »

Hi,

Could some one please help in applying following to an 16 bit grayscal(or RGB).

1. Invert LUT
2. Enhance Contrast ( Equalize Histogram)

I have uploaded the steps that i took to do same in ImageJ and the sample input image. Please help in doing exact same thing in Image Magick.

https://drive.google.com/folderview?id= ... sp=sharing


Thanks
Rathor
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Invert LUT and Equilize Histogram

Post by snibgo »

To equalise with IM, just use the "-equalize" operator.

IM doesn't contain operators for specialist processing of histograms (aka cluts) so I wrote some, as process modules. See my "Process modules" page. For example, to invert a clut, "-process invclut".

"[Adaptive] Contrast-limited equalisation" may also be of interest.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Invert LUT and Equilize Histogram

Post by fmw42 »

Why do you need to invert the lut? I am not sure what your end goal is? What does a LUT have to do with histogram equalization? Are you doing two separate steps? 1) apply some LUT via -clut, then 2) -equalize.

Convert your LUT to an image if necessary. Then -negate the lut image, then use -clut to apply it. Then do -equalize.

(unix syntax)

Code: Select all

convert image \( lutimage -negate \) -clut -equalize resultimage
(windows syntax)

Code: Select all

convert image ( lutimage -negate ) -clut -equalize resultimage
bhim.rathor
Posts: 21
Joined: 2016-02-21T13:47:15-07:00
Authentication code: 1151

Re: Invert LUT and Equilize Histogram

Post by bhim.rathor »

Hi,

Frankly i do no know what an Invert LUT does, but doing this gives me the image i want to see( A Brighter , metallic effect image).

These are 2 separate steps. I will apply your command shortly and update you about the result.

Thanks for your help

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

Re: Invert LUT and Equilize Histogram

Post by fmw42 »

If you cannot tell us what and inverted LUT is supposed to do, how can we know what to tell you to reproduce it in imagemagick?
bhim.rathor
Posts: 21
Joined: 2016-02-21T13:47:15-07:00
Authentication code: 1151

Re: Invert LUT and Equilize Histogram

Post by bhim.rathor »

Fred,

As per ImageJ , Invert LUT Inverts the current lookup table. For 8-bit images, the value (v) of each entry in the table is replaced by 255 − v. With inverted LUTs, pixels with a value of zero are white and pixels with a value 255 are black. Unlike the Edit▷Invert ↑ command, pixels values are not altered, only the way the image is displayed on the screen.

Full definition including equalize is available at http://rsbweb.nih.gov/ij/docs/guide/146-29.html

Please have a look and suggest something.

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

Re: Invert LUT and Equilize Histogram

Post by fmw42 »

My command above should do what you want. Repeated below:

Unix:

Code: Select all

convert image \( lutimage -negate \) -clut -equalize resultimage
Window:

Code: Select all

convert image ( lutimage -negate ) -clut -equalize resultimage
Doing the above is no different from but probably slightly faster than

Code: Select all

convert image -negate lutimage -clut -equalize resultimage
or

Code: Select all

convert image lutimage -clut -negate -equalize resultimage
The above assumes you have a LUT in image form. If you only have LUT values as a string or as a txt file, let us know and we can show you how to convert that into a LUT image.

Perhaps you should upload your image and lut to some free hosting service and put the URL here, so we can retrieve it and test with it.
Post Reply