# i was writing a code for mathematical morphology dilation operation for a 1D signal but did not get proper output. Kindly help me with the proper code

5 visualizzazioni (ultimi 30 giorni)
pavan sunder il 6 Ott 2016
Risposto: M E il 13 Lug 2019
the code i wrote:
function y_dil=dilation(x,se)
L=length(se)
x=[zeros(1,L) x];
N=length(x)
k=1+L;
y_dil=zeros(1,N);
for n=k:N
for i=1:L
r(i)=max(x(n-i)+se(i))
end
Y_dil(k-L)=max(r);
k=k+1;
end
end
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposte (2)

Massimo Zanetti il 6 Ott 2016
Use imdilate function which is already in Matlab. https://it.mathworks.com/help/images/ref/imdilate.html
For example, if your signal is SIGNAL matrix (1xN matrix), and your structuring element is SE=[1,1,1], try this:
DIL_SIGNAL = imdilate(SIGNAL,SE)
##### 4 CommentiMostra 2 commenti meno recentiNascondi 2 commenti meno recenti
Walter Roberson il 8 Ott 2016
A 1D signal is a very thin 2D signal ;-)
Massimo Zanetti il 8 Ott 2016
Hahahaha, true.

Accedi per commentare.

M E il 13 Lug 2019
Supporting the solution provided by Massimo, You can make costum length structuring elements:
DIL = imdilate(S,strel('line',Len,0))
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Morphological Operations in Help Center e File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by