Page 2 of 2

Re: Histograms in Photoshop CS6 vs. IM

Posted: 2013-05-30T16:16:06-07:00
by fmw42
There is one other way to do the histogram. That is to separate each channel, append and get the histogram from all channel data together. A global sort of histogram. This seems to be what PS is doing. That is probably what they mean by RGB composite


convert PhotoBoothXmas_0109.JPG -separate +append -define histogram:unique-colors=false histogram:hist6.png

Image

Your result from PS


Image

Prior to IM 6.8.5.0 you would need to add -set colorspace RGB before the -separate.



It is odd to me that this is not the same or equivalent to averaging the channels by

convert PhotoBoothXmas_0109.JPG -separate -evaluate-sequence mean -define histogram:unique-colors=false histogram:hist7.png

Image

which is the same as

convert PhotoBoothXmas_0109.JPG -colorspace OHTA -channel R -separate +channel -define histogram:unique-colors=false histogram:hist8.png

Image

Aside: In my redist script, the global histogram is one of many options that can be used.

Re: Histograms in Photoshop CS6 vs. IM

Posted: 2013-05-31T14:12:47-07:00
by blue-j
Yes! I came upon the same result and came to post it when I saw yours. The only thing is a type. I believe you intended to write

Code: Select all

convert PhotoBoothXmas_0109.JPG -separate -append -define histogram:unique-colors=false histogram:hist6.png
with a "-" before append, yes?

That is indeed the RGB histogram shown by PS. The other one, converting to gray first, is equivalent to the "Luminosity" histogram in PS.

Victory! Big thanks to all! I would buy you a drink if I could.

Appending is not the same as averaging. When you append, only the highest value is shown, hiding the lower values. When you average, you show the mean

That begs another question, which is, why would users want to see only a composites of the highest values, rather than the means of the values?

- J

Re: Histograms in Photoshop CS6 vs. IM

Posted: 2013-05-31T14:39:24-07:00
by GreenKoopa
-append joins top-to-bottom, +append joins left-to-right. Since all you want is the histogram, it doesn't matter.
blue-j wrote:When you append, only the highest value is shown, hiding the lower values.
When you append, won't all values (every channel of every pixel) show in the histogram?

Re: Histograms in Photoshop CS6 vs. IM

Posted: 2013-05-31T15:12:41-07:00
by fmw42
Appending is not the same as averaging. When you append, only the highest value is shown, hiding the lower values. When you average, you show the mean
I agree with GreenKoopa. Appending is not just showing the larger value. It is showing the histogram all the values R+G+B whereas averaging is getting the histogram of the averaged channels or (R+G+B)/3. Thus a scale factor of 3 or 1/3. The only difference might be (?) clipping if the sum is done and goes above 16 bits before the divide by 3. But I thought IM does all the processing in double precision floats. So I do not understand why it might clip.


Again, same as GreenKoopa. I used +append to append the images horizontally. But you would get the same result in this case of doing the histogram using -append to append the images vertically.
That is indeed the RGB histogram shown by PS. The other one, converting to gray first, is equivalent to the "Luminosity" histogram in PS.
It kind of makes sense from the names. RGB combined means get the data from all the channels and make the histogram. Luminosity histogram means get the histogram from the luminosity channel Y=rec601luma. Y is from YUV, YIQ, YCbCr, etc., which is the same as colorspace gray. see http://www.imagemagick.org/script/comma ... colorspace

Re: Histograms in Photoshop CS6 vs. IM

Posted: 2013-05-31T15:19:42-07:00
by snibgo
When you append, won't all values (every channel of every pixel) show in the histogram?
Yes. Averaging is a primitive form of greyscale conversion. Appending uses the actual values of each channel. The difference can be readily seen:

Code: Select all

convert xc:red xc:lime xc:blue -append test.png

convert test.png -separate -append -define histogram:unique-colors=false histogram:h3.png
convert test.png -separate -evaluate-sequence mean -define histogram:unique-colors=false histogram:h4.png
This is significant when, for example, we want to avoid clipping during further processing.

Re: Histograms in Photoshop CS6 vs. IM

Posted: 2013-05-31T15:25:26-07:00
by fmw42
That is a good example, snibgo. It would appear that it is a matter of putting the data into different bins rather than a clipping issue as I was just about to suggest. But your example makes it much clearer.

With the average here, you get 3 values of (255+0+0)/3 from rgb(255,0,0), rgb(0,255,0) and rgb(0,0,255). With all the channels you get 3 white (255) and 6 black (0) values. Great example.

Note the average (or mean) can also be obtained from the first channel of OHTA, which is not the same as colorspace gray. Colorspace gray is the same as luminosity, Y.

But your use of -separate -append and -separate -evaluate-sequence mean makes if very clear.

see also http://www.imagemagick.org/script/comma ... colorspace

Re: Histograms in Photoshop CS6 vs. IM

Posted: 2013-06-03T15:15:15-07:00
by blue-j
Thanks so much for sharing your knowledge. This has been very informative for me! I enjoy learning about imaging a lot and appreciate this community and the mentorship you all give me. Thanks again!

J