2026-07-08
This package contains some basic tools for one dimensional mathematical morphology. The standard reference for Mathematical Morphology is Serra (1982).
The functions is going to be plotted.
First, we show the erosion, dilation, opening and closing
of the original function.
se = -70:70
g = erosion(f=f,x=x,se=se)
df0 = data.frame(x,f,g)
p1 = ggplot(df0,aes(x=x,y=g))+geom_line() + ylim(0,1)
g_all = g
g = dilation(f=f,x=x,se=se)
df0 = data.frame(x,g)
p2 = ggplot(df0,aes(x=x,y=g))+geom_line()+ylim(0,1)
g_all = c(g_all,g)
g = opening(f=f,x=x,se=se)
df0 = data.frame(x,g)
p3 = ggplot(df0,aes(x=x,y=g))+geom_line()+ylim(0,1)
g_all = c(g_all,g)
g = closing(f=f,x=x,se=se)
df0 = data.frame(x,g)
p4 = ggplot(df0,aes(x=x,y=g))+geom_line()+ylim(0,1)
g_all = c(g_all,g)
df0 = data.frame(u=rep(x,4),v= g_all,
type = factor(rep(1:4,each=length(x)),levels=1:4,
labels=c("erosion","dilation","opening",
"closing")))
ggplot(df0,aes(x= u,y=v,color=type))+geom_line()Now the top-hat, bottom-hat, gradient and Beucher gradient.
se = -70:70
g = tophat(f=f,x=x,se=se)
df0 = data.frame(x,f,g)
p5 = ggplot(df0,aes(x=x,y=g))+geom_line() + ylim(0,1)
g_all = g
g = bottomhat(f=f,x=x,se=se)
df0 = data.frame(x,f,g)
p6 = ggplot(df0,aes(x=x,y=g))+geom_line() + ylim(0,1)
g_all = c(g_all,g)
df0 = data.frame(u=rep(x,2),v= g_all,
type = factor(rep(1:2,each=length(x)),levels=1:2,
labels=c("tophat","bottom-hat")))
ggplot(df0,aes(x= u,y=v,color=type))+geom_line()Two versions of the gradient using morphological tools.
se = -70:70
g = gradient(f=f,x=x,se=se)
df0 = data.frame(x,f,g)
p7 = ggplot(df0,aes(x=x,y=g))+geom_line() + ylim(0,1)
g_all = g
g = gradientB(f=f,x=x,se=se)
df0 = data.frame(x,f,g)
p8 = ggplot(df0,aes(x=x,y=g))+geom_line()
g_all = c(g_all,g)
g = gradExt(f=f,x=x,se=se)
df0 = data.frame(x,f,g)
p9 = ggplot(df0,aes(x=x,y=g))+geom_line() + ylim(0,1)
g_all = c(g_all,g)
g = gradInt(f=f,x=x,se=se)
df0 = data.frame(x,f,g)
p10 = ggplot(df0,aes(x=x,y=g))+geom_line() + ylim(0,1)
g_all = c(g_all,g)
df0 = data.frame(u=rep(x,4),v= g_all,
type = factor(rep(1:4,each=length(x)),levels=1:4,
labels=c("gradient","gradientB","gradExt",
"gradInt")))
ggplot(df0,aes(x= u,y=v,color=type))+geom_line()This a formalization of the concept of size distribution.
matrixLet us assume that we have a several functions observed at the same abscisas and there are provided as a matrix where each column corresponds with a different function.
[1] 201 20
listIf the functions have been observed at different durations then we can use to evaluate the granulometries the function granulometry_list().