pifMatch | R Documentation |
Match one scene to another based on linear regression of pseudo-invariant features (PIF).
pifMatch(
img,
ref,
method = "cor",
quantile = 0.95,
returnPifMap = TRUE,
returnSimMap = TRUE,
returnModels = FALSE
)
img |
SpatRaster. Image to be adjusted. |
ref |
SpatRaster. Reference image. |
method |
Method to calculate pixel similarity. Options: euclidean distance ('ed'), spectral angle ('sam') or pearson correlation coefficient ('cor'). |
quantile |
Numeric. Threshold quantile used to identify PIFs |
returnPifMap |
Logical. Return a binary raster map ot pixels which were identified as pesudo-invariant features. |
returnSimMap |
Logical. Return the similarity map as well |
returnModels |
Logical. Return the linear models along with the adjusted image. |
The function consists of three main steps:
First, it calculates pixel-wise similarity between the two rasters and identifies pseudo-invariant pixels based on
a similarity threshold.
In the second step the values of the pseudo-invariant pixels are regressed against each other in a linear model for each layer.
Finally the linear models are applied to all pixels in the img
, thereby matching it to the reference scene.
Pixel-wise similarity can be calculated using one of three methods: euclidean distance (method = "ed"
), spectral angle ("sam"
) or pearsons correlation coefficient ("cor"
).
The threshold is defined as a similarity quantile. Setting quantile=0.95
will select all pixels with a similarity above the 95% quantile as pseudo-invariant features.
Model fitting is performed with simple linear models (lm
); fitting one model per layer.
Returns a List with the adjusted image and intermediate products (if requested).
img
: the adjusted image
simMap
: pixel-wise similarity map (if returnSimMap = TRUE
)
pifMap
: binary map of pixels selected as pseudo-invariant features (if returnPifMap = TRUE
)
models
: list of linear models; one per layer (if returnModels = TRUE
)
library(terra)
## Create fake example data
## In practice this would be an image from another acquisition date
lsat_b <- log(lsat)
## Run pifMatch and return similarity layer, invariant features mask and models
lsat_b_adj <- pifMatch(lsat_b, lsat, returnPifMap = TRUE,
returnSimMap = TRUE, returnModels = TRUE)
## Pixelwise similarity
ggR(lsat_b_adj$simMap, geom_raster = TRUE)
## Pesudo invariant feature mask
ggR(lsat_b_adj$pifMap)
## Histograms of changes
par(mfrow=c(1,3))
hist(lsat_b[[1]], main = "lsat_b")
hist(lsat[[1]], main = "reference")
hist(lsat_b_adj$img[[1]], main = "lsat_b adjusted")
## Model summary for first band
summary(lsat_b_adj$models[[1]])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.