Provided by: gmt_4.5.11-1build1_amd64

**NAME**

grdhisteq - Histogram equalization for grid files

**SYNOPSIS**

grdhisteqin_grdfile[-Gout_grdfile] [-Cn_cells] [-D] [-N[norm] ] [-Q] [-V]

**DESCRIPTION**

grdhisteqallows the user to find the data values which divide a given grid file into patches of equal area. One common use ofgrdhisteqis in a kind of histogram equalization of an image. In this application, the user might have a grid of flat topography with a mountain in the middle. Ordinary gray shading of this file (using grdimage/grdview) with a linear mapping from topography to graytone will result in most of the image being very dark gray, with the mountain being almost white. One could usegrdhisteqto write to stdout an ASCII list of those data values which divide the range of the data inton_cellssegments, each of which has an equal area in the image. Usingawkormakecptone can take this output and build a cpt file; using the cptfile with grdimage will result in an image with all levels of gray occurring equally. Alternatively, seegrd2cpt. The second common use ofgrdhisteqis in writing a grid with statistics based on some kind of cumulative distribution function. In this application, the output has relative highs and lows in the same (x,y) locations as the input file, but the values are changed to reflect their place in some cumulative distribution. One example would be to find the lowest 10% of the data: Take a grid, rungrdhisteqand make a grid usingn_cells= 10, and then contour the result to trace the 1 contour. This will enclose the lowest 10% of the data, regardless of their original values. Another example is in equalizing the output ofgrdgradient. For shading purposes it is desired that the data have a smooth distribution, such as a gaussian. If you rungrdhisteqon output fromgrdgradientand make a grid file output with the Gaussian option, you will have a grid whose values are distributed according to a gaussian distribution with zero mean and unit variance. The locations of these values will correspond to the locations of the input; that is, the most negative output value will be in the (x,y) location of the most negative input value, and so on.in_grdfile2-D binary grid file to be equalized. (See GRID FILE FORMATS below).

**OPTIONS**

No space between the option flag and the associated arguments.-CSets how many cells (or divisions) of data range to make.-DDump level information to standard output.-GName of output 2-D grid file. Used with-Nonly. (See GRID FILE FORMATS below).-NGaussian output. Use with-Gto make an output grid with standard normal scores. Appendnormto force the scores to fall in the <-1,+1> range [Default is standard normal scores].-QUse quadratic intensity scaling. [Default is linear].-VSelects verbose mode, which will send progress reports to stderr [Default runs "silently"].

**GRID** **FILE** **FORMATS**

By defaultGMTwrites out grid as single precision floats in a COARDS-complaint netCDF file format. However,GMTis able to produce grid files in many other commonly used grid file formats and also facilitates so called "packing" of grids, writing out floating point data as 2- or 4-byte integers. To specify the precision, scale and offset, the user should add the suffix=id[/scale/offset[/nan]], whereidis a two-letter identifier of the grid type and precision, andscaleandoffsetare optional scale factor and offset to be applied to all grid values, andnanis the value used to indicate missing data. When reading grids, the format is generally automatically recognized. If not, the same suffix can be added to input grid file names. Seegrdreformat(1) and Section 4.17 of the GMT Technical Reference and Cookbook for more information. When reading a netCDF file that contains multiple grids,GMTwill read, by default, the first 2-dimensional grid that can find in that file. To coaxGMTinto reading another multi-dimensional variable in the grid file, append?varnameto the file name, wherevarnameis the name of the variable. Note that you may need to escape the special meaning of?in your shell program by putting a backslash in front of it, or by placing the filename and suffix between quotes or double quotes. The?varnamesuffix can also be used for output grids to specify a variable name different from the default: "z". Seegrdreformat(1) and Section 4.18 of the GMT Technical Reference and Cookbook for more information, particularly on how to read splices of 3-, 4-, or 5-dimensional grids.

**EXAMPLES**

To find the height intervals that divide the file heights.grd into 16 divisions of equal area:grdhisteqheights.grd-C16-D> levels.d To make the poorly distributed intensities in the file raw_intens.grd suitable for use withgrdimageorgrdview, rungrdhisteqraw_intens.grd-Gsmooth_intens.grd-N-V

**RESTRICTIONS**

If you usegrdhisteqto make a gaussian output for gradient shading ingrdimageorgrdview, you should be aware of the following: the output will be in the range [-x, x], where x is based on the number of data in the input grid (nx * ny) and the cumulative gaussian distribution function F(x). That is, let N = nx * ny. Then x will be adjusted so that F(x) = (N - 1 + 0.5)/N. Since about 68% of the values from a standard normal distribution fall within +/- 1, this will be true of the output grid. But if N is very large, it is possible for x to be greater than 4. Therefore, with thegrdimageprogram clipping gradients to the range [-1, 1], you will get correct shading of 68% of your data, while 16% of them will be clipped to -1 and 16% of them clipped to +1. If this makes too much of the image too light or too dark, you should take the output ofgrdhisteqand rescale it usinggrdmathand multiplying by something less than 1.0, to shrink the range of the values, thus bringing more than 68% of the image into the range [-1, 1]. Alternatively, supply a normalization factor with-N.

**SEE** **ALSO**

gmtdefaults(1),GMT(1),grd2cpt(1),grdgradient(1),grdimage(1),grdmath(1),grdview(1),makecpt(1)