IM equivalent of GIMP - Levels - Output

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?".
rossdv8
Posts: 47
Joined: 2014-03-12T21:54:20-07:00
Authentication code: 6789

IM equivalent of GIMP - Levels - Output

Post by rossdv8 »

In GIMP > Colors > Levels there are options to adjust:

Input Levels
0 Gamma 255

Output Levels
0 255


For a repetitive GIMP task I need to adjust:
Color > Saturation > 25
Color > Curves > Sigmoidal
Colour > Levels >
Input Levels
10 Gamma 1.5 255
Output Levels
20 235

I have managed to create a script, probably probably I modified several of Anthony's, to achieve the saturation, S-curve and input levels and Gamma. This almost achieves what I want, but I stillneed to go to GIMP and modify the output levels. I would really like to do the whole thing in ImageMagick.

What I cannot find anywhere is advice on how to modify a script to achieve the 20 - 335 output level using IM. I cannot even find a reference anywhere to these output levels and their relationship to IM.

Can someone please point me in the direction of something that will explain enough for me to add this final step to a script?

Thanks,

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

Re: IM equivalent of GIMP - Levels - Output

Post by snibgo »

Gimp "Levels, Output levels" seems to decrease contrast just like IM's "+level". 20/255 = 7.84%. 235/255 = 92.16%. So I suggest:

Code: Select all

+level 7.84,92.16%
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: IM equivalent of GIMP - Levels - Output

Post by fmw42 »

Output values are controlled by +level as snibgo suggested. Curves can be done via -sigmoidal-contrast. Saturation via -modulate.

If on Linux/Mac OS or Windows with Cygwin, see my scripts levels, curves, sigmoidal, saturation and vibrance at the link below.
rossdv8
Posts: 47
Joined: 2014-03-12T21:54:20-07:00
Authentication code: 6789

Re: IM equivalent of GIMP - Levels - Output

Post by rossdv8 »

Thanks snibgo,

I often wonder why I should need to adjust both input output levels, as well as applying a sigmoidal curve, but I need to apply this correction across a fairly wide selection of images and the settings I use work pretty well except with really bad images.

I'm still looking for detailed information about what you just told me (output levels and contrast) and I'll combine trying your suggestion with reading more closely about IM and Levels. I must have missed something there.

Cheers,

RossD.
rossdv8
Posts: 47
Joined: 2014-03-12T21:54:20-07:00
Authentication code: 6789

Re: IM equivalent of GIMP - Levels - Output

Post by rossdv8 »

Thank you Fred,

I have looked at your scripts often, but after some serious injuries and a brain infection I no longer think quite the way I did when I was programming, which I suppose started in the early 70's. So now I do a lot of 'read, test, modify, write'. I avoid using your scripts because some of the stuff I create goes into making some small gift articles I might sell some time, and you ask people not to use your scripts commercially.

So while I've found a few of your scripts that do exactly what I want, I refrain from using them or Anthony's or from copying parts of them. I just explore everything I can find about IM and practice bits from the tutorials until I find something I can modify enough or combine with other things to achieve a result.

For the same reason I avoid actually using snippets such as snibgo provided, preferring instead to try the suggestion in something I am working on. It all ends up in the mix I suppose, because there are only so many variations on a theme.

And a note to snibgo,
I n all my searching IM stuff I never found your page of tips. Thank you.

Thanks again to people here.

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

Re: IM equivalent of GIMP - Levels - Output

Post by snibgo »

For IM's level, see http://www.imagemagick.org/script/comma ... .php#level

That documentation doesn't say, but both percentages can be < 0 or > 100. This means that -level can be used instead of +level, with a suitable change of percentages.

A quick experiment with Gimp suggests it is the same as +level. But perhaps it is more sophisticated.
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: IM equivalent of GIMP - Levels - Output

Post by fmw42 »

snibgo wrote:For IM's level, see http://www.imagemagick.org/script/comma ... .php#level

That documentation doesn't say, but both percentages can be < 0 or > 100. This means that -level can be used instead of +level, with a suitable change of percentages.

A quick experiment with Gimp suggests it is the same as +level. But perhaps it is more sophisticated.
You can do what snibgo says, but using -level with values <0 or >100 does not give the exact same results as using +level with values >0 and <100. However, the effects are similar.

I generally find that using values >0 and <100 with both -level and +level does the better job.
rossdv8
Posts: 47
Joined: 2014-03-12T21:54:20-07:00
Authentication code: 6789

Re: IM equivalent of GIMP - Levels - Output

Post by rossdv8 »

Thanks again to both Fred and snibgo.

I've had a look at snibgo's scripts for the first time and like Fred's, some are fascinating. Unfortunately I remember very little about Windows or even MS Dos (haven't had MS or Mac since 1998) so for the moment I am stuck with writing my own little scripts and if they work, linking them and making them executable.

I'll look deeper into IM and -levels and +levels. I never really understood the difference. I suppose I thought - and + were just taking the changes in different directions.

UPDATE

I re-read http://www.imagemagick.org/script/comma ... .php#level and checked in GIMP. it seems you are right. running a command with -levels and gamma, follwed by another with +levels could very well be the solution.

Thanks again. Sometimes I'm just too exhausted to actually read what I am looking at. Sorry for the dumb questions when the answer was already there. :D
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: IM equivalent of GIMP - Levels - Output

Post by fmw42 »

I suppose I thought - and + were just taking the changes in different directions.
They are. -levels takes the values from given and makes them black and white (so a stretch -- more contrast). +level takes the values at 0 100 and changes them to the values provided (so a compression -- less contrast).
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: IM equivalent of GIMP - Levels - Output

Post by fmw42 »

I re-read http://www.imagemagick.org/script/comma ... .php#level and checked in GIMP. it seems you are right. running a command with -levels and gamma, follwed by another with +levels could very well be the solution.
That is what I do, however, I add some contrast-stretch as an option (as in Photoshop). You can add -sigmoidal-contrast and -modulate, etc to achieve whatever combination you need.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: IM equivalent of GIMP - Levels - Output

Post by fmw42 »

So while I've found a few of your scripts that do exactly what I want, I refrain from using them or Anthony's or from copying parts of them. I just explore everything I can find about IM and practice bits from the tutorials until I find something I can modify enough or combine with other things to achieve a result.
I admire your spirit. The only way to really learn is try lots of things and figure out what is most efficient. There are often many ways to approach a problem.
rossdv8
Posts: 47
Joined: 2014-03-12T21:54:20-07:00
Authentication code: 6789

Re: IM equivalent of GIMP - Levels - Output

Post by rossdv8 »

Thank you,

This all started because I was looking for a simple way to use GIMP from the command line to execute a series of operations. A google search brought me to IM instead, which took me to Fred's ImageMagick scripts and a lot of reading, then to the IM site and Anthony's tutorials and examples, thence here.

A lot of work has gone into ImageMagick and I was disappointed to find GraphicsMagick as the default in Clem's Mint 17. It took me a while to realise why my scripts were not working after updating, then some fiddling to remove GM and get IM to install into Mint 17.

I am finding ImageMagick can do probably automate everything I did manually in GIMP.
Ok, I should stop using this post as a chat. My apologies, and again thanks for the help.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: IM equivalent of GIMP - Levels - Output

Post by snibgo »

For "-level", we give the input values for which we want the output values to be 0 and 100%. If the given values are between 0 and 100%, this will increase contrast.

For "+level", we give the output values for which we want the input values to be 0 and 100%. If the given values are between 0 and 100%, this will decrease contrast.

However, some brigtness-contrast adjustments can't be done in a single level with both given values within 0..100%. For example, if we want output=50% at input=0, and output=100% at input=50%, we can use one of the following commands:

Code: Select all

convert g.png -level -50%,50% g2.png

convert g.png +level 50%,150% g3.png

convert g.png -level 0,50% +level 50%,100% g4.png
snibgo's IM pages: im.snibgo.com
rossdv8
Posts: 47
Joined: 2014-03-12T21:54:20-07:00
Authentication code: 6789

Re: IM equivalent of GIMP - Levels - Output

Post by rossdv8 »

Thanks. That's a clear description. As far as colours go I have IM producing almost exactly the output I get from GIMP, except that with GIMP the detail is sharper and things like the folds on a shirt cast sharper shadows.
No amount of messing with IM in a simple way seems to overcome that, yet in GIMP it simply happens by adjusting the settings as shown in the original post.

Using +level is not doing anything useful, and fine adjustments to S-curve and to -level does not give me back the contrasting shadow I get in GIMP. I am looking at the thngs you (snibgo) do to your donkey and grass to see if there is an easy way to enhance the detail and get the same detail I get in GIMP. Probably something as simple as adding some sort of unsharp operation.

I'll keep playing. Thanks people.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: IM equivalent of GIMP - Levels - Output

Post by fmw42 »

Perhaps if you post an example with the input, IM output and command, and GIMP output and arguments, we might be able to suggest something to you. You can upload your images to some free hosting service such as dropbox.com (public folder) and put the URLs here.

One thing I found with Photoshop is that do some slight clip in the options panel of levels, that I assume is about like using -auto-level at the start (or -contrast-stretch 0.1%) . Perhaps GIMP is doing the same.

The other issue to be careful about is the use of different profiles between systems. GIMP may be assigning a different profile than what you have in the image or you may need to assign a profile in IM to match what is being done in GIMP. However, I do not see how that would help sharpness or shadows.
Post Reply