is this histogram output correct?

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
josephaaroncampbell
Posts: 40
Joined: 2015-07-14T19:18:45-07:00
Authentication code: 1151
Location: Chicago, IL

is this histogram output correct?

Post by josephaaroncampbell »

The magick code in batch file:

Code: Select all

 magick convert -quiet input.tif -colorspace gray -gravity center -crop 60%% -format %%c histogram:info:- >> %~dp0hist.txt
Reading from a grayscale image, part of this histogram output is:
1: ( 2, 2, 2) #020202 gray(2)
1: ( 5, 5, 5) #050505 gray(5)
2: ( 5, 5, 5) #050505 gray(5)
1: ( 7, 7, 7) #070707 gray(7)
1: ( 7, 7, 7) #070707 gray(7)
1: ( 7, 7, 7) #070707 gray(7)
3: ( 8, 8, 8 ) #080808 gray(8)
1: ( 9, 9, 9) #090909 gray(9)
1: ( 10, 10, 10) #0A0A0A gray(10)
3: ( 10, 10, 10) #0A0A0A gray(10)
4: ( 11, 11, 11) #0B0B0B gray(11)
1: ( 13, 13, 13) #0D0D0D gray(13)
1: ( 14, 14, 14) #0E0E0E gray(14)
1: ( 14, 14, 14) #0E0E0E gray(14)
1: ( 17, 17, 17) #111111 gray(17)
1: ( 20, 20, 20) #141414 gray(20)
1: ( 21, 21, 21) #151515 gray(21)
1: ( 22, 22, 22) #161616 gray(22)
2: ( 24, 24, 24) #181818 gray(24)
4: ( 25, 25, 25) #191919 gray(25)
I am wondering why (7, 7, 7) is listed three times with a pixel count of 1 for each. is this being miscounted or are there three separate pixels with gray(7) as their value? Same question for the other values that are repeated, such as 5, 10, 14, ...etc.

I am using the histogram output to find the peak and other spike values, so i need to know the relevant histogram bin value where the spike is. with grayscale, i was thinking its gray(x) value would be the same as its bin location.

but since the gray values repeat, maybe i am not thinking of this correctly?

Thank You..


--------------------------------------------------------------------------------------------------------
Version: ImageMagick 7.0.3-5 Q16 x64 2016-11-08
Visual C++: 180040629
Features: Cipher DPC HDRI Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib

windows 10 pro 64bit
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: is this histogram output correct?

Post by snibgo »

You are using HDRI. After "-colorspace gray", it is unlikely that any pixels are exactly #070707. I suspect that you have three pixels that are close to this, but they have different values. You also have three pixels close to (or exactly) #080808, but they are the same value.

Sadly, IM hase no operation that makes pixels integer values. Instead, you can write to an integer-only format such as PNG, and read that.
snibgo's IM pages: im.snibgo.com
miket
Posts: 60
Joined: 2016-08-12T13:19:13-07:00
Authentication code: 1151

Re: is this histogram output correct?

Post by miket »

I'm running into similar issues (early days yet ;) ).

Am I correct in assuming (in Perl Magic) that once an HRD image is read in, it is not sufficient just to change the magick file number to a PNG to force the data to integer values, but the file would have to be written and re-read for the conversion to take place?

As more of us are using HDRi, I would certainly vote for a feature to be added to the histogram function so that the histogram could be binned appropriately (say, 0-100, 0-255, 0-65535)

Mike
miket
Posts: 60
Joined: 2016-08-12T13:19:13-07:00
Authentication code: 1151

Re: is this histogram output correct?

Post by miket »

........ adding a channel selector would also be really useful :)

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

Re: is this histogram output correct?

Post by snibgo »

miket wrote:Am I correct in assuming (in Perl Magic) that once an HRD image is read in, it is not sufficient just to change the magick file number to a PNG to force the data to integer values, but the file would have to be written and re-read for the conversion to take place?
That is correct for the command-line interface. I doubt that such a feature has been added merely for Perl.

A trick that seems to work, to strip the fractional part, is "-evaluate Xor 0", eg:

Code: Select all

convert in.miff -evaluate Xor 0 out.miff
snibgo's IM pages: im.snibgo.com
miket
Posts: 60
Joined: 2016-08-12T13:19:13-07:00
Authentication code: 1151

Re: is this histogram output correct?

Post by miket »

Thanks snibgo - I'll give that a go :)
Post Reply