finding the co-ordinates

12 visualizaciones (últimos 30 días)
kash
kash el 25 de Abr. de 2012
I have a matrix as
S=[0 0 0 0 0 0 0 0 0 0 0
0 0 0 1 1 1 1 0 0 0 0
0 0 0 1 1 1 1 0 0 0 0
0 0 0 1 1 1 1 0 0 0 0
0 0 0 1 1 1 1 0 0 0 0
0 0 0 1 1 1 1 0 0 0 0]
in this i want to find the position of ones so that i can draw the bounding box over ones please help how to processs

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 25 de Abr. de 2012
st = regionprops(S, 'BoundingBox' )
eg:
z = randi(15,size(S))
ij = ceil(st.BoundingBox);
out = z(ij(2) + (0:ij(4)-1),ij(1) + (0:ij(3)-1))
added after the Kash's comment
Img = imread('Q8vjJ.png');
BW = im2bw(Img,graythresh(Img));
BW(:,1) = false;
BW2 = cumsum(BW,2) & fliplr(cumsum(BW(:,end:-1:1),2));
BW2 = cumsum(BW2) & flipud(cumsum(BW2(end:-1:1,:)));
st = regionprops(SBW2, 'BoundingBox' );
imcrop(Img,st.BoundingBox + [-1 -1 1 1]);
  3 comentarios
kash
kash el 25 de Abr. de 2012
Andrei i get error
Error using ==> ceil
Too many input arguments.
for my image
http://imgur.com/Q8vjJ
please help
kash
kash el 25 de Abr. de 2012
I need just a bounding box over the white regions (i.e) the text,but the image is cropped .i dont want to crop the image just a bounding box over it

Iniciar sesión para comentar.

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