finding pixel near border

1 visualización (últimos 30 días)
Mohammad Golam Kibria
Mohammad Golam Kibria el 10 de Ag. de 2011
Hi, I have a matrix as follows:
I =
1 0 0 0 0 1
0 1 0 0 1 0
0 1 0 1 0 0
0 0 1 0 0 0
0 1 0 1 1 0
1 0 0 0 0 1
here 4 ones are in the total matrix boundary position. Is there any easy way that will return me the position of those pixel i.e. for this matrix (1,1),(6,1),(1,6),(6,6) thanks in advance.

Respuesta aceptada

Friedrich
Friedrich el 10 de Ag. de 2011
Hi,
maybe this:
I =[
1 0 0 0 0 1
0 1 0 0 1 0
0 1 0 1 0 0
0 0 1 0 0 0
0 1 0 1 1 0
1 0 0 0 0 1 ];
[x y] = size(I);
tmp = zeros(x,y);
tmp(1,:) = ones(1,y);
tmp(x,:) = ones(1,y);
tmp(:,1) = ones(x,1);
tmp(:,y) = ones(x,1);
[i j] = find(I.*tmp == 1);
disp([i,j])
  2 comentarios
Mohammad Golam Kibria
Mohammad Golam Kibria el 10 de Ag. de 2011
Thanks
Andrei Bobrov
Andrei Bobrov el 10 de Ag. de 2011
a = eye(size(I))
a = a(:,end:-1:1)+a
a(2:end-1,2:end-1)=0
find(I & a)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Standard File Formats en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by