I have two rasters (Landsat slc-off images) in R. Both are missing some data, but the gap locations are completely offset. As an example, I create two rasters
r1 <- raster(system.file("external/test.grd", package="raster")) r1_mat <- as.matrix(r1) r1[which(!is.na(as.matrix(r1)))[1:600]] <- NA par(mfrow=c(3,1)) plot(r1) r2 <- raster(system.file("external/test.grd", package="raster")) r2[which(!is.na(as.matrix(r2)))[900:1400]] <- NA plot(r2)
However, the second image is taken under different atmospheric conditions, say, with better solar illumination. To simulate this effect (very simply):
r2 <- r2 + 200
Now I would like to fill the missing data in r1, with r2 pixels that overlap the gaps which is trivially:
r3 <- cover(r1, r2) plot(r3)
Looking at the result of
plot(r3), the so called "stripping effect" also shown in Figure 2 on this page here is apparent. One of the recommended solutions is to normalize the two images by matching their histograms before doing the gap filling. The technique is based on the cumulative distribution functions of the candidate images e.g. as will be done in Grass 7.
How exactly can I achieve this in R? Thanks!