1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
\
.\" This man page was generated by the Netpbm tool 'makeman' from HTML source.
.\" Do not hand-hack it! If you have bug fixes or improvements, please find
.\" the corresponding HTML page on the Netpbm website, generate a patch
.\" against that, and send it to the Netpbm maintainer.
.TH "Pgmhist User Manual" 1 "18 December 2021" "netpbm documentation"
.SH NAME
pgmhist - print a histogram of the values in a PGM image
.UN synopsis
.SH SYNOPSIS
\fBpgmhist\fP
[\fB-median\fP, \fB-quartile\fP, \fB-decile\fP]
[\fB-forensic\fP]
[\fB-machine\fP]
[\fIpgmfile\fP]
.UN description
.SH DESCRIPTION
.PP
This program is part of
.BR "Netpbm" (1)\c
\&.
.PP
\fBpgmhist\fP reads a PGM image as input and prints a histogram of the
gray values or other gray value distribution metrics.
.PP
If you specify none of \fB-median\fP, \fB-quartile\fP, or \fB-decile\fP,
\fBpgmhist\fP prints a complete histogram showing how many pixels of each
possible gray value exist in the image. Along with each gray value, it tells
you how many pixels are at lest as black as it and how many are at least as
white.
.PP
\fB-median\fP, \fB-quartile\fP, and \fB-decile\fP options cause
\fBpgmhist\fP instead to print the indicated quantiles. Each quantile is a
gray value that actually appears in the image (as opposed to fractional values
that are sometimes used for quantiles). The 3rd quartile is the least gray
value for which at least 75% of the pixels are as dark or darker than it.
The 4th quartile is the brightest gray value that appears in the image.
.UN options
.SH OPTIONS
.PP
In addition to the options common to all programs based on libnetpbm
(most notably \fB-quiet\fP, see
.UR index.html#commonoptions
Common Options
.UE
\&), \fBpgmhist\fP recognizes the following
command line options:
.PP
You may specify at most one of \fB-median\fP, \fB-quartile\fP, and
\fB-decile\fP. If none of these is specified \fBpgmhist\fP prints
a histogram of gray values.
.TP
\fB-median\fP
.sp
This option causes \fBpgmhist\fP to print the median gray value.
.sp
This option was new in Netpbm 10.61 (December 2012).
.TP
\fB-quartile\fP
.sp
This option causes \fBpgmhist\fP to print the four quartile gray values.
.sp
This option was new in Netpbm 10.61 (December 2012).
.TP
\fB-decile\fP
.sp
This option causes \fBpgmhist\fP to print the ten decile gray values.
.sp
This option was new in Netpbm 10.61 (December 2012).
.TP
\fB-forensic\fP
.sp
With this option, \fBpgmhist\fP works on images that contain invalid gray
values. Normally, like most Netpbm programs, \fBpgmhist\fP fails if it
encounters a gray value greater than the maxval that the image declares. The
presence of such a value means the image is invalid, so the pixels have no
meaning. But with \fB-forensic\fP, \fBpgmhist\fP produces a histogram
of the actual gray values without regard to maxval. It issues messages
summarizing the invalid pixels if there are any.
.sp
One use for this is to diagnose the problem that caused the invalid Netpbm
image to exist.
.sp
There is a small exception to the ability of \fBpgmhist\fP to process
invalid pixels even with \fB-forensic\fP: it can never process a gray value
greater than 65535. Note that in the rarely used Plain PGM format, it is
possible for a number greater than that to appear where a gray value belongs.
.sp
This option was new in Netpbm 10.66 (March 2014). But Netpbm older than
10.66 does not properly reject invalid sample values, so the effect is very
similar to \fB-forensic\fP.
.TP
\fB-machine\fP
.sp
This option causes \fBpgmhist\fP to print the information in a way
easily digestible by a machine as opposed to a human.
.sp
For the quantiles, there is one line per quantile, in quantile order, and
it consists of the gray value of the quantile in decimal with no leading
zeroes.
.sp
For the full histogram output, it consists of one line per possible
gray value (whether that value appears in the image or not), in order of
the gray values. The line consists of two tokens separated by a space. The
first is the gray value; the second is the number of pixels in the image that
have that gray value. Both are decimal numbers without leading zeroes.
.sp
This option was new in Netpbm 10.61 (December 2012).
.UN seealso
.SH SEE ALSO
.BR "pnmnorm" (1)\c
\&,
.BR "ppmhist" (1)\c
\&,
.BR "pgm" (1)\c
\&
.UN author
.SH AUTHOR
Copyright (C) 1989 by Jef Poskanzer.
.SH DOCUMENT SOURCE
This manual page was generated by the Netpbm tool 'makeman' from HTML
source. The master documentation is at
.IP
.B http://netpbm.sourceforge.net/doc/pgmhist.html
.PP
|