Hyperspectral image acquisition normaly causes spatial misalignment between the spectral bands (layers) due to both equipment (such as band-to-band recording delay) and external factors (e.g. sensor vibrations). In this case, a geometric correction is necessary for remote sensing applications such as combining/merging spectral bands. This function uses the HOG (Histogram of Oriented Gradient) descriptor in order to find the optimal translations (xy shift) on multiple 'slave' bands to be spatially align with a 'master' (reference) band. Parallel processing is allowed.

registerBrick(
  Brick,
  ref_layer = 1,
  layers = "all",
  ncells = 24,
  orient = 8,
  cl = NULL
)

Arguments

Brick

An object of class RasterBrick or RasterStack (from package raster), containing multiple layers (spectral bands).

ref_layer

An integer indicating which layer (spectral band) should be used as reference ('master') to register all the others from. Default is 1, the first band.

layers

Either the character "all" (default), which indicates that all bands should be registered using ref_layer as reference, or a vector of integers specifying which bands to register.

ncells

An integer giving the number of cells to compute the oriented gradients of the HOG descriptor. Default is 24. See OpenImageR::HOG().

orient

An integer giving the number of orientations to compute the oriented gradients of the HOG descriptor. Default is 8. See OpenImageR::HOG().

cl

An integer indicating the number of parallel processes or an object created by parallel::makeCluster(). Default if NULL.

Value

An object of the same classe as the input slave, with the fixed extent.

Details

This should be used carefully, as rotation affects the spatial dimensions. The affine parameters are estimated using a general optimization algorithm.

See also

Examples

path <- system.file('exdata', 'obory.dat', package = 'hyperbrick')
dpath <- system.file('exdata', 'obory_dark.dat', package = 'hyperbrick')
im <- buildBrick(path, hFOV = 36.8, vFOV = 36.8, height = 45,
                 ref_layer = 35, spectral_feature = 'radiance',
                 dark_path = dpath)
print(im)
#> class      : RasterBrick 
#> dimensions : 128, 128, 16384, 81  (nrow, ncol, ncell, nlayers)
#> resolution : 0.2338986, 0.2338986  (x, y)
#> extent     : 512700.2, 512730.1, 5769447, 5769477  (xmin, xmax, ymin, ymax)
#> crs        : +proj=utm +zone=34 +datum=WGS84 +units=m +no_defs 
#> source     : memory
#> names      :     b500,     b505,     b510,     b515,     b520,     b525,     b530,     b535,     b540,     b545,     b550,     b555,     b560,     b565,     b570, ... 
#> min values : 0.000000, 0.000000, 2.585766, 2.698176, 3.072813, 3.356975, 2.944080, 3.060960, 2.966433, 3.053820, 3.254400, 3.122134, 3.044976, 3.042847, 3.336410, ... 
#> max values :  0.00000,  0.00000, 65.48363, 66.57010, 69.16295, 69.86433, 69.11280, 67.55280, 67.58897, 68.89113, 67.66618, 68.18915, 69.35350, 71.70908, 73.55206, ... 
#> 
plotRGB(im, r = 63, g = 34, b = 11, stretch = 'lin')


imreg <- registerBrick(im, ref_layer = 35, layers = c(63, 34, 11))
imreg
#> class      : RasterBrick 
#> dimensions : 126, 126, 15876, 3  (nrow, ncol, ncell, nlayers)
#> resolution : 0.2338986, 0.2338986  (x, y)
#> extent     : 512700.5, 512730, 5769447, 5769477  (xmin, xmax, ymin, ymax)
#> crs        : +proj=utm +zone=34 +datum=WGS84 +units=m +no_defs 
#> source     : memory
#> names      :     b810,     b665,     b550 
#> min values : 4.374972, 2.655258, 3.254400 
#> max values : 76.22636, 87.43409, 67.66618 
#> 
plotRGB(imreg, stretch = 'lin')