Learn R Programming

RStoolbox (version 0.2.4)

rescaleImage: Linear Image Rescaling

Description

performs linear shifts of value ranges either to match min and max of another image (y) or to any other min and max value (ymin and ymax).

Usage

rescaleImage(x, y, xmin, xmax, ymin, ymax, forceMinMax = FALSE)

Arguments

x

Raster* object. Image to normalise.

y

Raster* object. Reference image. Optional. Used to extract min and max values if ymin or ymax are missing.

xmin

Numeric. Min value of x. Either a single value or one value per layer in x. If xmin is not provided it will be extracted from x.

xmax

Numeric. Max value of x. Either a single value or one value per layer in x. If xmax is not provided it will be extracted from x.

ymin

Numeric. Min value of y. Either a single value or one value per layer in x. If ymin is not provided it will be extracted from y.

ymax

Numeric. Max value of y. Either a single value or one value per layer in x. If ymax is not provided it will be extracted from y.

forceMinMax

Logical. Forces update of min and max data slots in x or y.

Value

Returns a Raster* object of the same dimensions as the input raster x but shifted and stretched to the new limits.

Details

Providing xmin and xmax values manually can be useful if the raster contains a variable of a known, fixed value range, e.g. NDVI from -1 to 1 but the actual pixel values don't encompass this entire range. By providing xmin = -1 and xmax = 1 the values can be rescaled to any other range, e.g. 1 to 100 while comparability to other rescaled NDVI scenes is retained.

See Also

histMatch

Examples

Run this code
# NOT RUN {
## Create example data
data(lsat)
lsat2 <- lsat - 1000
lsat2

## Rescale lsat2 to match original lsat value range
lsat2_rescaled <- rescaleImage(lsat2, lsat)
lsat2_rescaled

## Rescale lsat to value range [0,1]
lsat2_unity <- rescaleImage(lsat2, ymin = 0, ymax = 1)
lsat2_unity
# }

Run the code above in your browser using DataLab