grdmix — GMT 6.1.1 documentation

# grdmix

Blending and transforming grids and images

## Synopsis

gmt grdmix raster1 [ raster2 [ raster3]] -G outfile [ -A alpha ] [ -C ] [ -D ] [ -I intensity ] [ -M ] [ -N[i|o][factor] ] [ -Q ] [ -R region ] [ -V[level] ] [ -W weights ] [ -f flags ] [ --PAR=value ]

Note: No space is allowed between the option flag and the associated arguments.

## Description

grdmix will perform various operations involving images and grids. We either use a alpha grid, image, or constant to add a new alpha (transparency) layer to the image given as raster1, or we will blend the two raster1 and raster2 (grids or images) using the weights for raster1 and the complementary 1 - weights for raster2 and save to outfile. Alternatively, we will deconstruct an image into its component (red, green, blue or gray) grid layers or we construct an image from its normalized component grids. All operations support adjusting the final color image via an intensity grid, converting a color image to monochrome, or strip off the alpha layer. All raster?, alpha, intensity and weights files must have the same dimensions. The optional alpha, intensity and weights files may be replaced by constant values instead.

## Required Arguments

raster?

  If only one is given and -C is not set then raster1 must be an image. If two are given then raster1 and raster2 must both be either images or grids. If three are given then they must all be grids and -C must be set.

-Goutfile

  The name for the output raster. For images, use one of these extensions: tif (GeoTIFF), gif, png, jpg, bmp, or ppm.

## Optional Arguments

-Aalpha

  Get a constant alpha (0-1), or a grid (0-1) or image (0-255) with alphas. The final image will have a transparency layer add based on these values.

-C

  Construct an output image from one or three normalized input grids; these grids must all have values in the 0-1 range only (see -Ni if they don’t). Optionally, use -A to add transparency and -I to add intensity to the colors before writing the image. For three layers the input order must be red grid first, then the green grid, and finally the blue grid.

-D

  Deconstruct a single image into one or three output grids. An extra grid will be written if the image contains an alpha (transparency layer). All grids written will reflect the original image values in the 0-255 range exclusively; however, you can use -No to normalize the values to the 0-1 range. The output names uses the name template given by -G which must contain the C-format string “%c”. This code is replaced by the codes R, G, B and A for color images and g, A for gray-scale images.

-Iintensity

  A constant intensity or grid (-1 to +1 range) to modify final output image colors.

-M

  Force conversion to monochrome image using the (television) YIQ transformation.

-N[i|o][factor]

  Normalize all input grids from 0-255 to 0-1 and all output grids from 0-1 to 0-255. To only turn on normalization for input or output, use -Ni or -No instead. To normalize by another factor than 255, append an optional factor value.

-Q

  Make the final image opaque by removing the alpha layer (if present).

-Rxmin/xmax/ymin/ymax[+r][+uunit] (more …)

  Specify the region of interest.

-V[level] (more …)

  Select verbosity level [w].

-Wweights

  A constant weight (0-1), or a grid (0-1) or image (0-255) with weights. When two input rasters are given, the weights are applied to raster1 and (1-weights) are applied to raster2, then the products are summed.

-f[i|o]colinfo (more …)

  Specify data types of input and/or output columns.

-^ or just -

  Print a short message about the syntax of the command, then exit (NOTE: on Windows just use -).

-+ or just +

  Print an extensive usage (help) message, including the explanation of any module-specific option (but not the GMT common options), then exit.

-? or no arguments

  Print a complete usage (help) message, including the explanation of all options, then exit.

--PAR=value

  Temporarily override a GMT default setting; repeatable. See gmt.conf for parameters.

## Grid File Formats

By default GMT writes out grid as single precision floats in a COARDS-complaint netCDF file format. However, GMT is 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 1- or 2-byte integers. (more …)

## Examples

Note: Below are some examples of valid syntax for this module. The examples that use remote files (file names starting with `@`) can be cut and pasted into your terminal for testing. Other commands requiring input files are just dummy examples of the types of uses that are common but cannot be run verbatim as written.

To blend the night and day views of the Earth using a weight image computed for a particular day/night terminus, try:

    gmt grdmix @earth_day_06m @earth_night_06m -W@weight.png -Gnewmap.png

Suppose map1.png and map2.png are overlapping maps of different quantities, but we wish to use the image visible.png to blend them into a single image: Where visible.png has values close to 255 we will see predominantly the map1.png contents while for values closer to zero we will mostly see map2.png - values in between these extremes will lead to a weighted average. We try:

    gmt grdmix map1.png map2.png -Wvisible.png -Gnewmap.png -V

To insert the values from the grid transparency.grd into the image gravity.tif as an alpha (transparency) layer, and write out a transparent PNG image, try:

    gmt grdmix gravity.tif -Atransparency.grd -Gmap.png

To break the color image layers.png into separate, normalized red, green, and blue grids (and possibly an alpha grid), we run:

    gmt grdmix layers.png -D -Glayer_%c.grd -No

To recombine the three normalized grids red.grd, green.grd, and blue.grd into a TIFF file, but applying intensities from intens.grd and add transparency from transp.grd grids, try:

    gmt grdmix red.grd green.grd and blue.grd -Glayer.tif -Atransp.grd -Iintens.grd

## See Also

gmt, grdblend, grdclip, grdcut, grdinfo, grdsample