Page 2 of 3
Re: IM equivalent of GIMP - Levels - Output
Posted: 2014-07-14T15:30:14-07:00
by snibgo
IM is (usually) 16-bit but Gimp is 8-bit. Operations in Gimp with curves or levels can result in visible banding.
Re: IM equivalent of GIMP - Levels - Output
Posted: 2014-07-14T16:52:38-07:00
by rossdv8
Thanks Fred,
I generally use IM to strip ICC profiles before I use either GIMP or IM for processing. I suppose I should instead use IM to strip any ICC profile, then assign something simple like sRBG. However I often work in LAB or HSL/HSB so I generally just strip any existing profile.
Your reply reminds me that GIMP, I believe, works by default in RGB and assigns an RGB profile to anything non specific.
I wonder what IM does if I strip profiles. Does IM assume sRGB? I will have to investigate that. I will post an example of a GIMP image and an IM image using the setting I've talked about. I have my own web sites left over from the days when I was working, so I'll simply put a folder in one of those for this exercise.
Re: IM equivalent of GIMP - Levels - Output
Posted: 2014-07-14T17:30:41-07:00
by snibgo
If the channels are red, green and blue, then IM assumes sRGB unless told otherwise. But most operations are purely arithmetical, and are independent of colorspace.
Re: IM equivalent of GIMP - Levels - Output
Posted: 2014-07-14T17:34:19-07:00
by fmw42
For me GIMP always wants to assign an sRGB profile. IM will not overwrite any profile. If it has one, it keeps it. If has none (and is 3 channel data, ie not cmyk), it assumes sRGB, except for a few image types which may be linear RGB. I am not sure which ones, possibly PBM. However assuming sRGB and adding a profile may end up being viewed or processed differently. You would probably be better safest always assigning the same profile in both cases.
Re: IM equivalent of GIMP - Levels - Output
Posted: 2014-07-14T19:36:06-07:00
by rossdv8
Thanks,
Here's an example of what I am playing with. I deliberately picked a photo where the camera has left the image all muddy on a beautiful day here. I added far too much saturation in the sky (for a reason) and pulled the sand and sea closer to what they really are.
The images don;t match exactly, but they are close. I should add that I output my IM stuff as PNG, and I haven't done one as a JPEG to see if I have a difference there.
However if you look carefully at the centre and right hand crops (bottom) you can see where I'm losing a lot of shadows. It is nit picking I suppose, but I am curious about using a simple script at the command line to get as close as possible to the exact result as GIMP.
I once rewrote a 36 page program a company was using, down to 7 lines that did the job. I like 'simple'. Anyway, here's what I am doing:
http://rossdevitt.com/IM/
I wrote this into a simple web page to post here, but I'll also repeat it on this post.
In GIMP Open 'Colors' then Hue and Saturation, and for this example we chose 40%. Next, open Colors and Curves and apply a farly standard Sigmoidal curve. That cuts the haze, boosts the colours and creates some contrast. Finally by opening Colors and Levels I can adjust the left side of the scale to fine tune the dark end and bump the Gamma to in this case, 1.5.
In ImageMagick something similar is achieved with
-convert wh.jpg -modulate 100,140 -sigmoidal-contrast 6,46% -level 5,100%,1.5 IM-enhanced.png
So far I have had no luck with +level for the equivalent of Colors > Levels ? Output level in GIMP. All +level has done for me is create havoc with saturation. While I was experimenting with +level I discovered this issue with the shadows and spent several hours trying to fine tune it so they match.
Thanks
Re: IM equivalent of GIMP - Levels - Output
Posted: 2014-07-14T20:01:08-07:00
by fmw42
You have very sensitive "eyes". I had to look very carefully to see any visual difference. But I suppose photographers might be a bit more picky than me.
My guess is that IM -sigmoidal-contrast does not match well enough to the curve you are using in GIMP. Do you have some present curve for GIMP? I do not know if you can adjust your IM sigmoidal-contrast values to match the curve you have in GIMP. But I would suggest you play with the IM values a bit more.
Even my curves script might not match whatever interpolation method they use in GIMP. But you could try recording the control point values and use my script with those values to test, if you are on Linux/Mac OS or Windows with Cygwin.
Re: IM equivalent of GIMP - Levels - Output
Posted: 2014-07-14T20:18:35-07:00
by snibgo
Looking at your crops, I would say they are equally sharp. (Both over-sharpened, probably from whatever made the original jpeg.) The main difference for the shirt shadows is that they are darker in the Gimp version. This increases the contrast with the lighter portions of the shirt, which increases apparent sharpness.
There are also clear differences in the red shoes. The yellow hat is almost identical in each.
How did you decide "-sigmoidal-contrast 6,46%" was the same as the curve you applied in Gimp? This might be where the difference comes from.
Re: IM equivalent of GIMP - Levels - Output
Posted: 2014-07-14T20:25:30-07:00
by fmw42
Seems like both snibgo and I agree here that it is likely the limitations of the curves emulation by IM sigmoidal-contrast.
Was your GIMP curve symmetric? How many points did you pick? Your IM -sigmoidal-contrast is not quite symmetric.
Nevertheless, I doubt you can duplicate the GIMP curve exactly with IM sigmoidal-contrast. There is no reason that GIMP would be creating a curve that matches the limitations of the IM sigmoidal curve function.
In my script, curves, I try to smoothly interpolate between a few points using a Catmull-Rom spline. In my past testing of my curves script, even that does not match perfectly with the same points applied in Photoshop Curves (and likely not in GIMP curves). But that may be closer than using a sigmoidal function.
Re: IM equivalent of GIMP - Levels - Output
Posted: 2014-07-14T20:42:42-07:00
by snibgo
Yes, we cross-posted but thought alike.
If the Gimp curve is saved as a preset, the data goes into file gimp-curves-tool.settings in directory %USERPROFILE%\.gimp-2.8\tool-options . (Other presets go into similar files.) This is a text file, easily readable. I have a (unpublished) program to convert Gimp curves into IM cluts. It could be done by script.
I don't know what method Gimp uses, Catmull-Rom or whatever, but the file gives 256 samples which is usually enough that there is no visible difference between methods.
Re: IM equivalent of GIMP - Levels - Output
Posted: 2014-07-14T21:12:17-07:00
by fmw42
snibgo wrote:
If the Gimp curve is saved as a preset, the data goes into file gimp-curves-tool.settings in directory %USERPROFILE%\.gimp-2.8\tool-options . (Other presets go into similar files.) This is a text file, easily readable. I have a (unpublished) program to convert Gimp curves into IM cluts. It could be done by script.
I don't know what method Gimp uses, Catmull-Rom or whatever, but the file gives 256 samples which is usually enough that there is no visible difference between methods.
Yes, that is better idea than just taking the picked points and trying to replicate the interpolated curve via spline. I did not know that GIMP provided denser list of interpolated points rather than just the points picked. Nice to know that. I will have to check Photoshop to see if they do the same.
Another way (as you know), would be to use a HALD clut. Apply the GIMP curve to the a HALD image and then bring that back to IM to apply.
http://www.imagemagick.org/Usage/color_mods/#hald-clut
Re: IM equivalent of GIMP - Levels - Output
Posted: 2014-07-14T21:44:00-07:00
by rossdv8
The numbers used for the S-curve were trial and error until the result in IM matched as close as possible the curve I use for quick fixes in GIMP, which, as someone suggested, is also not quite symetrical. I have tried fine tuning the numbers further on the assumption that it is one end of the curve that is losing my shadows.
This is the GIMP curve:
http://www.rossdevitt.com/IM/curve.jpg
I'm pretty pleased with the result as it is, I'm just being fussy because I am sure someone else will try to do this some time. I never imagined being able to take so many actions usually done individually one after another in GIMP and roll them into one simple entry at a command line. Or now, just clicking on a script. Because with IM I can now click one script file, and all images in a directory are processed. Ideally each image should be adusted based on its individual histogram, but for convenience, adjusting 100 images with one click while I go and make a coffee, just can't be beaten. This is where IM shines.
Re: IM equivalent of GIMP - Levels - Output
Posted: 2014-07-14T21:51:41-07:00
by fmw42
If you are going to be applying the same process exactly to lots of images and do want to make it closer, then use snibgo's method of extracting the curve points to a clut or use my technique using HALD clut image. The HALD process may be easier, since you do not have to convert the GIMP preset for the curve to an IM lut. All you need to do is create a HALD image (-hald 8, for example) and take it to GIMP. Open it and apply the same curve you used before to it. Save as PNG (do not use a compressed format such as jpg). Then bring back the modified hald image to IM and apply it using -hald-clut. See my link above.
In fact, since you have no blurring and only point operations to adjust color, brightness and contrast, you can apply your whole GIMP processing to the HALD image and just use one simple command to apply the hald image with -hald-clut. You won't need -modulate, -sigmoidal-contrast, etc. Just apply the hald image.
Re: IM equivalent of GIMP - Levels - Output
Posted: 2014-07-14T22:02:36-07:00
by rossdv8
Ok, thanks everyone.
I think I found a way to fix the shadow. In GIMP, levels and sigmoidal curves are able to be adjusted separately, as in fact they can in IM.
However, for a particular reason in GIMP I only adjust the left (black) side of the level graph from 0 to 10, but do not adjust the right (white) end. I leave it at 255. I ImageMagick I use -level 5,100% to achieve what I thought is the same thing.
I then use a numbers in IM that give me a similar result overall to the S-curve I use in GIMP.
It seems however I can get back some of the contrast difference between GIMP and IM by pulling the -level numbers back from 5,100% to 5,95% or a little more.
Again, thanks for the help and suggestions. And the original question of this post, about matching GIMP's output level has been answered early. Using +level is not easy, but does eventually produce something similar.
I can now roll this script into a couple of others to make what is effectively a small uncompiled program to save myself a lot of repetitive work
![Very Happy :D](./images/smilies/icon_biggrin.gif)
Re: IM equivalent of GIMP - Levels - Output
Posted: 2014-07-14T22:03:28-07:00
by fmw42
In fact, since you have no blurring and only point operations to adjust color, brightness and contrast, you can apply your whole GIMP processing to the HALD image and just use one simple command to apply the hald image with -hald-clut. You won't need -modulate, -sigmoidal-contrast, etc. Just apply the hald image. Bonus, it is very fast, so would help if you have lots of images to process.
Re: IM equivalent of GIMP - Levels - Output
Posted: 2014-07-14T22:56:33-07:00
by rossdv8
Thanks Fred and Alan (I think), I took that bit of information and am reading the info Anthony has posted about HALD, but not understanding it at all. One of the joys of chronic illness is the toll it takes on what used to be mental ability
But I will see if I can understand it. Until then, the script will give me almost what I want. I never expected to have to apply math or keyboard commands to computing again in these days of point and click.