diff options
Diffstat (limited to 'pnmhisteq.html')
-rw-r--r-- | pnmhisteq.html | 198 |
1 files changed, 198 insertions, 0 deletions
diff --git a/pnmhisteq.html b/pnmhisteq.html new file mode 100644 index 00000000..458b3389 --- /dev/null +++ b/pnmhisteq.html @@ -0,0 +1,198 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN"> +<HTML><HEAD><TITLE>Pnmhisteq User Manual</TITLE></HEAD> +<BODY> +<H1>pnmhisteq</H1> +Updated: 10 September 2005 +<BR> +<A HREF="#index">Table Of Contents</A> + +<A NAME="lbAB"> </A> +<H2>NAME</H2> + +pnmhisteq - histogram equalize a PNM image + +<A NAME="lbAC"> </A> +<H2>SYNOPSIS</H2> + +<B>pnmhisteq</B> + +[<B>-gray</B>] + +[<B>-rmap</B> <I>pgmfile</I>] + +[<B>-wmap</B> <I>pgmfile</I>] + +[<B>-verbose</B>] + +[<I>pnmfile</I>] + + +<P>You can abbreviate any option to its shortest unique prefix. + + +<A NAME="lbAD"> </A> +<H2>DESCRIPTION</H2> + +<p>This program is part of <a href="index.html">Netpbm</a>. + +<p><B>pnmhisteq</B> increases the contrast of a PGM or PPM image +through the technique of "histogram equalization."[1] + +<p><b>pnmhisteq</b> computes a histogram of the luminosity of the +pixels in the image. It then calculates a mapping between each +luminosity and a new luminosity such that it spreads out intensity +levels around histogram peaks and compresses them at troughs. I.e. +it moves pixels around in the histogram so as to make it flat. It +applies that mapping to the input image to produce the output image. +The effect of this is that the image has equal numbers of pixels at each +possible intensity level, which means it uses the available levels of +intensity more efficiently and thereby has more visible detail. + +<P>Mathematically, the luminosity mapping is this: Assume the pixels +are sorted by luminosity into <i>B</i> buckets numbered from 0 (lowest +luminosity) to <i>B</i>-1. <i>N[i]</I> is the number of pixels in +bucket <I>i</I>. <I>T</I> is the total number of pixels (sum of +<i>N[i]</i> over all <i>i</i>). <i>W</i> is the luminosity of white. + +<p><b>pnmhisteq</b> replaces an input pixel whose luminosity falls into +bucket <i>j</i> with one whose luminosity is: + +<pre> + + j + --- + \ + > (N[i] / T) * W + / + --- + i=0 +</pre> + +<p>Considering a grayscale image for simplicity, this means that +pixels in the most luminous bucket become white. Pixels in the 10th +per centile of luminosity become 10% of white. + + +<P>If you're processing a related set of images, for example frames of +an animation, it's generally best to apply the same luminosity mapping +to every frame, since otherwise you'll get distracting frame-to-frame +changes in the brightness of objects. <B>pnmhisteq</B>'s <B>-wmap</B> +option allows you to save, as a PGM image, the luminosity map it +computes from an image. The <b>-rmap</b> option causes <b>pnmisteq</b> +to use such an image as its luminosity map. + +<p>So you can run <b>pnmhisteq</b> with <b>-wmap</b> on a composite +you created with <b>pnmcat</b> of the images you intend to process. +Then, you can run <b>pnmisteq</b> with <b>-rmap</b> on each of the +individual images, using the luminosity map you generated from the +composite. + + +<A NAME="lbAE"> </A> +<H2>OPTIONS</H2> + +<DL COMPACT> +<DT><B>-gray</B> + +<DD>When processing a pixmap, only gray pixels (those with identical +red, green, and blue values) are included in the histogram and +modified in the output image. This is a special purpose option +intended for images where the actual data are gray scale, with color +annotations you don't want modified. Weather satellite images that +show continent outlines in color are best processed using this option. +The option has no effect when the input is a graymap. + +<DT><B>-rmap</B> <I>mapfile</I> + +<DD>Process the image using the luminosity map specified by the PGM +file <I>mapfile</I>. + +The PGM image, usually created by an earlier run of <B>pnmhisteq</B> +with the <B>-wmap</B> option, contains a single row with number of +columns equal to the maxval (greatest intensity value) of the image +plus one. Each pixel in the image is transformed by looking up its +luminosity in the corresponding column in the map file (column number += luminosity) and changing it to the value given by that column. + +<DT><B>-wmap</B> <I>mapfile</I> + +<DD>Creates a PGM file <I>mapfile</I>, containing the luminosity map +computed from the histogram of the input image. This map file can be +read on subsequent runs of <B>pnmhisteq</B> with the <B>-rmap</B> +option, allowing a group of images to be processed with an identical +map. + +<DT><B>-verbose</B> + +<DD>Prints the histogram and luminosity map on Standard Error. + +</DL> + +<A NAME="lbAF"> </A> +<H2>LIMITATIONS</H2> + +<p>Histogram equalization is effective for increasing the visible +detail in scientific imagery and in some continuous-tone pictures. It +is often too drastic, however, for scanned halftone images, where it +does an excellent job of making halftone artifacts apparent. You +might want to experiment with <B>pnmnorm</B> and <B>pnmgamma</B> for +more subtle contrast enhancement. + +<P>The luminosity map file supplied by the <B>-rmap</B> option must +have the same maxval as the input image. This is always the case when +the map file was created by the <B>-wmap</B> option of +<B>pnmhisteq</B>. If this restriction causes a problem, simply adjust +the maxval of the map with <B>pamdepth</B> to agree with the input +image. + +<P>If the input is a PBM file (on which histogram equalization is an +identity operation), the only effect of passing the file through +<B>pnmhisteq</B> will be the passage of time. + +<A NAME="lbAG"> </A> +<H2>SEE ALSO</H2> + +<B><A HREF="pnmnorm.html">pnmnorm</A></B>, + +<B><A HREF="pnmcat.html">pnmcat</A></B>, + +<B><A HREF="pamdepth.html">pamdepth</A></B>, + +<B><A HREF="pnmgamma.html">pnmgamma</A></B>, + +<B><A HREF="pnm.html">pnm</A></B>, + +<DL COMPACT> +<DT>[1] + +<DD>Russ, John C. The Image Processing Handbook. Boca Raton: CRC +Press, 1992. Pages 105-110. + +</DL> + +<A NAME="lbAH"> </A> +<H2>AUTHOR</H2> + +<p>Copyright (C) 1995 by John Walker (<A +HREF="mailto:kelvin@fourmilab.ch">kelvin@fourmilab.ch</A>). WWW home +page: <A HREF="http://www.fourmilab.ch/">http://www.fourmilab.ch/</A> + +<P>Permission to use, copy, modify, and distribute this software and +its documentation for any purpose and without fee is hereby granted, +without any conditions or restrictions. This software is provided +"as is" without express or implied warranty. + +<HR> +<A NAME="index"> </A> +<H2>Table Of Contents</H2> +<UL> +<LI><A HREF="#lbAB">NAME</A> +<LI><A HREF="#lbAC">SYNOPSIS</A> +<LI><A HREF="#lbAD">DESCRIPTION</A> +<LI><A HREF="#lbAE">OPTIONS</A> +<LI><A HREF="#lbAF">BUGS</A> +<LI><A HREF="#lbAG">SEE ALSO</A> +<LI><A HREF="#lbAH">AUTHOR</A> +</UL> +</BODY> +</HTML> |