how to find max neighbour pixel in a 8-cordinated window?
3 views (last 30 days)
Show older comments
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)
0 Comments
Answers (1)
Sean de Wolski
on 8 Oct 2013
Extract the neighborhood into its own variable and set the middle value to -inf
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!