how to find connected neighbors?

2 visualizaciones (últimos 30 días)
jenifer Ask
jenifer Ask el 13 de Nov. de 2019
Respondida: KSSV el 13 de Nov. de 2019
How do I find a neighbor of pixels with a neighbor whose value is 1?
(Loop to find connected neighbors)
I tried to run the operation on this code but failed
[y,x] = find(I) ;
figure
imshow(I)
hold on
plot(x,y,'.b')
i=x(100)
j=y(100)
neighbors(1) = I(i-1,j-1);
plot(i-1,j-1,'*r')
neighbors(2) = I(i-1,j);
plot(i-1,j,'*r')
neighbors(3) = I(i-1,j+1);
plot(i-1,j+1,'*r')
neighbors(4) = I(i,j-1);
plot(i,j-1,'*r')
neighbors(5) = I(i,j+1);
plot(i,j+1,'*r')
neighbors(6) = I(i+1,j-1);
plot(i+1,j-1,'*r')
neighbors(7) = I(i,j);
plot(i,j,'*r')
neighbors(8) = I(i+1,j);
plot(i+1,j,'*r')
neighbors(9) = I(i+1,j+1);
plot(i+1,j+1,'*r')

Respuesta aceptada

KSSV
KSSV el 13 de Nov. de 2019
If you know the location of the pixel..uou can use knnsearch or rangeseach. YOu can also search in mathworks, this question has been addressed multiple times.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by