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

3 ビュー (過去 30 日間)
sheno39
sheno39 2013 年 10 月 8 日
回答済み: Sean de Wolski 2013 年 10 月 8 日
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)

回答 (1 件)

Sean de Wolski
Sean de Wolski 2013 年 10 月 8 日
Extract the neighborhood into its own variable and set the middle value to -inf

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by