1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
# Regional maxima
dilatation.geodesique <- function (x, y, r) {
for (i in 1:r) {
# On prend la 4-distance et la 8-distance une fois sur deux :
# ça correspond a une boule octogonale.
if ( i %% 2 == 0 ) {
x <- dilatation(x, structuring.element.plus) & y
} else {
x <- dilatation(x, structuring.element.square()) & y
}
}
x
}
r.h.maxima <- function (x,r,h) {
res <- matrix(F, nr=dim(x)[1], nc=dim(x)[2])
for (n in 1:255) {
res <- res | (
(x>n) & ! dilatation.geodesique(x>n+h, x>n, r)
)
}
res
} |
Partager