# Sampling-Free Morphology - MATLAB Sources

Here you will find the sources for the sampling-free morphology presented in:

• C.L. Luengo Hendriks and L.J. van Vliet, Basic morphological operations, band-limited images and sampling, in: L.D. Griffin and M. Lillholm (eds.), Proceedings of the 4th International Conference, Scale-Space 2003 (Isle of Skye, United Kingdom, June 10-12), LNCS 2695, pp. 313-324, Springer, 2003.

These scripts are written for MATLAB with the DIPimage toolbox. The ZIP file below contains a couple of M-files to create and process one-dimensional signals represented as a series of polynomials:

• The function CMSEGMENT converts a sampled signal into a series of polynomial segments. If the signal is over-sampled, the resulting polynomials are an accurate representation of the original continuous function, but if the high-frequency content is large, the cubic splines used cannot correctly interpolate in the sampled image.
• The function CMSAMPLE does the inverse, converting a series of polynomial segments into a sampled signal. If the input signal is band-limited, and a sufficiently large sampling density is chosen, the resulting sampled image is a correct representation of the input signal.
• CMDILATION and CMEROSION apply the dilation and erosion, with a flat, compact structuring element, to the input signal, which must be in the polynomial segment representation. CMEROSION works by inverting the signal, calling CMDILATION, and inverting the signal again.
• CMINVERT inverts a signal in the polynomial segment representation.
• CMINTEGRATE integrates a signal in the polynomial segment representation.

Thus, the following sequence of MATLAB commands apply a closing to a sampled signal and integrate the result:

x = xx(200,'corner');
din = 1 + sin(x*2*pi/(200/9));

cin = cmsegment(din);
cout = cmerosion(cmdilation(cin,10),10);
cres = cmintegrate(cout)

The following code does the same using discrete morphology:

dout = closing(din,10);
dres = sum(dout)

To look at the result of the sampling-free closing, use

figure; hold on
plot(double( cmsample(cin,[],10) ),'k-');
plot(double( din ),'kx');
plot(double( cmsample(cout,[],10) ),'b-');
plot(double( dout ),'ro');