Effacer les filtres
Effacer les filtres

how to find max neighbour pixel in a 8-cordinated window?

2 vues (au cours des 30 derniers jours)
sheno39
sheno39 le 8 Oct 2013
i have made a code.. it is not working properly. i need to find maximum neighbour pixel for each pixels by considering only its neighbor pixels(i.e.) surounding 8 pixels.In my code it takes 9 pixels. how to correct my code? can anyone help me.
I=[2 3 10 4 6; 1 4 7 5 3; 5 2 8 4 3;8 2 1 7 3;1 9 8 3 4;];
D = padarray(I,[1 1],0,'both');
[x y]=size(D);
m=1;
n=1;
for i=2:x-1
for j=2:y-1
I1(m,n)=max(max(D(i-1:i+1,j-1:j+1)));
n=n+1;
end
m=m+1;
n=1;
end
I1=I1(1:x-2,1:y-2);
size(D)
size(I1)

Réponses (1)

Sean de Wolski
Sean de Wolski le 8 Oct 2013
Extract the neighborhood into its own variable and set the middle value to -inf

Catégories

En savoir plus sur Image Segmentation and Analysis dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by