Page 1 of 2
Histograms in Photoshop CS6 vs. IM
Posted: 2013-05-30T12:27:51-07:00
by blue-j
First, thanks so much to all the developers and community! IM is astounding, and your efforts are very sincerely appreciated.
I'm investigating the histogram displays in Photoshop CS6 (13.0.4) and comparing them with IM 6.8.0-2. Wow, PS is doing some unusual things! First, for the Colors option, Adobe's display scales the normal 256x200 IM output down 80%, then crops off the top, so it's 100px high. Any idea why they would do that? So odd! (And trust me, I am not assuming that Adobe's work is superior here).
Second, I cannot for the life of me get a histogram out of IM that resembles their "RGB" or composite histogram (or even their lumosity histogram). IM's is remarkably different. I am trying this:
Code: Select all
convert input_file.jpg -separate -append -define histogram:unique-colors=false -write histogram:mpr:hgram +delete mpr:hgram -strip output_file.gif
Anyone have a notion of where the differences come from?
Here are the files and histograms (zip) for comparison:
http://bit.ly/1aF59jA
Thanks so much for your time in considering this!!
J
Re: Histograms in Photoshop CS6 vs. IM
Posted: 2013-05-30T12:56:10-07:00
by fmw42
The photoshop color histogram looks quite like the IM histogram except for the fact that PS crops it. I have no idea why unless they want to amplify the small counts. The main difference is that when IM overlays each color, it is done additively so that red+green+blue look white. PS appears to replace the white with mid gray.
With regard to the grayscale histogram that could be a color space issue, depending upon what version of IM you are using. You do not say what command you used to make it grayscale.
try
convert image -set colorspace RGB -colorspace gray -define histogram:unique-colors=false histogram:grayscale_histogram.gif
Or just use
convert image -modulate 100,0,100 define histogram:unique-colors=false histogram:grayscale_histogram.gif
In your version of IM -grayscale converted the image to linear grayscale with gamma=1 and you probably need a non-linear grayscale with gamma=0.4545 to match PS
Re: Histograms in Photoshop CS6 vs. IM
Posted: 2013-05-30T13:14:54-07:00
by snibgo
I don't know PS so can't comment on that.
Two points about IM histograms:
1. I like to add a black border, otherwise a peak at either end can get lost when a viewer displays against a white background.
2. For grayscale intensity, different methods of conversions to gray can yield very different results. Eg (IM 6.8.5-0 on Windows 7):
Code: Select all
convert rose: -grayscale Lightness histogram:- | convert - -bordercolor Black -border 1 h1.png
convert rose: -grayscale Brightness histogram:- | convert - -bordercolor Black -border 1 h2.png
Re: Histograms in Photoshop CS6 vs. IM
Posted: 2013-05-30T13:27:05-07:00
by fmw42
I do not think that -grayscale was available at 6.8.0.2, but I could be mistaken.
Re: Histograms in Photoshop CS6 vs. IM
Posted: 2013-05-30T13:43:49-07:00
by snibgo
Ah, that's true. It was introduced for 6.8.5.
Re: Histograms in Photoshop CS6 vs. IM
Posted: 2013-05-30T13:47:01-07:00
by blue-j
I'm very appreciative of your help!
I am not converting the image to grayscale. I was following the counsel and copying the code from here:
http://www.imagemagick.org/Usage/files/#histogram
starting "On the other hand a better 'global' histogram can be generated by simply separating all the color channels in the original image and appeneding. The resulting histogram is a representation of all the color values regarless [sic] of which channel that value is from."
but perhaps this was assuming the image was converted to grayscale beforehand? Sounds like it?
Attempting to follow your counsel, I tried:
Code: Select all
convert input_file.jpg -set colorspace RGB -grayscale -define histogram:unique-colors=false -write histogram:mpr:hgram +delete mpr:hgram -strip output_file.gif
Code: Select all
convert input_file.jpg -set colorspace RGB - grayscale -gamma 0.45455 -define histogram:unique-colors=false -write histogram:mpr:hgram +delete mpr:hgram -strip output_file.gif
Code: Select all
convert input_file.jpg -modulate 0,100,0 -define histogram:unique-colors=false -write histogram:mpr:hgram +delete mpr:hgram -strip output_file.gif
Code: Select all
convert input_file.jpg -smodulate 0,100,0 -gamma 0.45455 -define histogram:unique-colors=false -write histogram:mpr:hgram +delete mpr:hgram -strip output_file.gif
None had the same result. I apologize in advance if I misapplied your advice, and thank you again for your time in investigating this matter!
J
Re: Histograms in Photoshop CS6 vs. IM
Posted: 2013-05-30T13:56:20-07:00
by blue-j
snibgo wrote:Ah, that's true. It was introduced for 6.8.5.
Does this mean that I must upgrade to =>6.8.5 in order to test your proposed code using the -grayscale switch?
Thanks again,
J
Re: Histograms in Photoshop CS6 vs. IM
Posted: 2013-05-30T13:56:33-07:00
by snibgo
1. Note that "-separate" is a greyscale operation (it separates a colour image into 3 greyscale images). It gives different results in 6.8.4 and 6.8.5. I generally suggest that people who use greyscale upgrade to 6.8.5.
2. Your "-modulate 0,100,0" is very different to Fred's suggestion: "-modulate 100,0,100".
Re: Histograms in Photoshop CS6 vs. IM
Posted: 2013-05-30T14:01:39-07:00
by blue-j
snibgo wrote:1. Note that "-separate" is a greyscale operation (it separates a colour image into 3 greyscale images). It gives different results in 6.8.4 and 6.8.5. I generally suggest that people who use greyscale upgrade to 6.8.5.
2. Your "-modulate 0,100,0" is very different to Fred's suggestion: "-modulate 100,0,100".
I will try to upgrade. I had trouble last time I tried as a dependency failed to build using Macports.
I mistyped. I in fact did try 100,0,100 (desating the image).
Peace,
J
Re: Histograms in Photoshop CS6 vs. IM
Posted: 2013-05-30T14:10:38-07:00
by blue-j
snibgo wrote:I don't know PS so can't comment on that.
I understand! I did however provide the PS histograms, in case you are curious about what they are displaying.
Thanks again!
J
Re: Histograms in Photoshop CS6 vs. IM
Posted: 2013-05-30T14:39:32-07:00
by fmw42
There are lots of ways in IM to convert to grayscale. I have no idea what PS is using. The most common ones are convert to rec601luma, demodulate (in various colorspace), average the channels. Each one can be done in a linear or non-linear manner.
Just doing the obvious in IM 6.8.5.8 (which does not need the -set colorspace RGB),
convert PhotoBoothXmas_0109.JPG -colorspace gray -define histogram:unique-colors=false histogram:hist3.png
If I open your image in my old PS CS and convert to grayscale and look at the histogram, I get the following. Except for the scaling, it looks similar to mine above.
The above is a bit different from demodulating
convert PhotoBoothXmas_0109.JPG -modulate 100,0,100 -define histogram:unique-colors=false histogram:hist10.png
Colorspace profiles may also affect the result. PS may override the colorspace in the image with its own if you have not set up the Color Settings panel appropriately.
Re: Histograms in Photoshop CS6 vs. IM
Posted: 2013-05-30T15:09:29-07:00
by blue-j
What you've shown looks very similar to the "Luminosity" histogram when you are in RGB mode (not converting to Grayscale) in CS6 (yet again, PS crops the top off). It also does look like the composite histogram in PS after converting to Grayscale.
The "RGB" composite histogram looks meaningfully different (the one I posted). I suspect something other than converting to grayscale first may be at work there? I'm curious.
Thanks so much again! Sorry to strain your patience. I am not a person who thinks that it's ideal to match PS, but this is a learning experience for me to understand more about histograms and what PS and IM are representing with them.
- J
Re: Histograms in Photoshop CS6 vs. IM
Posted: 2013-05-30T15:25:38-07:00
by GreenKoopa
I don't use Photoshop often nor have access to test at the moment, but I do have two ideas. First, Photoshop uses an approximation for generating image statistics. In a GUI environment where the histogram window may always be showing, this is a practical necessity for processor load. This approximating may cause your height clipping. There was some way to force an update when needed. Second, to fmw42's idea of amplifying small counts, Photoshop does have a logarithm scaled histogram mode. Your histograms didn't look log scaled though.
I agree that looking into different or unexpected results often leads to a deeper understanding.
Re: Histograms in Photoshop CS6 vs. IM
Posted: 2013-05-30T15:39:41-07:00
by blue-j
GreenKoopa wrote:I don't use Photoshop often nor have access to test at the moment, but I do have two ideas. First, Photoshop uses an approximation for generating image statistics. In a GUI environment where the histogram window may always be showing, this is a practical necessity for processor load. This approximating may cause your height clipping. There was some way to force an update when needed.
Yes, PS offers the ability to build a histogram based on cached image data rather than the actual original data in order to speed up results, but the differences between the two modes don't account for discrepancies we've reported in this thread. It's not related to the cropping. I think that Adobe decided those outliers don't have practical value to the user, and that's why they are truncated. Not sure. I'm not going to crop them out.
Basically, Fred has presented the solution for mirroring PS's "luminosity" histograms, it seems, but we don't yet know what they are doing to present their "RGB" or composite histograms. (I have yet to test individual channel histograms). I'm waiting a bit for ImageMagick to update to 6.8.5-5 so version is not a factor...
- J
Re: Histograms in Photoshop CS6 vs. IM
Posted: 2013-05-30T15:58:05-07:00
by snibgo
I might add that Gimp's "value" histogram of the image is similar (but not identical) to PS's and IM's.