Segment grid boxes

rgb = imread('peppers.png');
imshow(rgb)
hold on
M = size(rgb,1);
N = size(rgb,2);
for k = 1:25:M
x = [1 N];
y = [k k];
plot(x,y,'Color','w','LineStyle','-');
plot(x,y,'Color','k','LineStyle',':');
end
for k = 1:25:N
x = [k k];
y = [1 M];
plot(x,y,'Color','w','LineStyle','-');
plot(x,y,'Color','k','LineStyle',':');
end
hold off
Suppose I want to segment and extract individual areas of the grid .. How do I go about it ? Like, which boundary detection algorithm is used for this purpose ?

2 comentarios

Sean de Wolski
Sean de Wolski el 25 de Mzo. de 2011
Post an image! How do you expect us to figure anything out when we can't see what you're doing!
Siddharth Mallya
Siddharth Mallya el 27 de Mzo. de 2011
http://img703.imageshack.us/i/gridg.png/
This is my image. If I want to segment each block of the grid, should I crop it each time ? or should I use some other approach ?

Iniciar sesión para comentar.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 12 de Abr. de 2011

0 votos

Regular rectangular grids, or potentially irregular spacing?
If it is a regular rectangular grid, crop to contain only full cells, detect the grid line separation, then mat2cell() or blkproc() or blockproc()

3 comentarios

Siddharth Mallya
Siddharth Mallya el 14 de Abr. de 2011
Right now I am using this in my program,
for i = fr1:31:lc1
for j = fc1:21:N
letter = imcrop (img, [j i 21 31]);
Works fine .. but takes quite a bit of time to process.
Walter Roberson
Walter Roberson el 14 de Abr. de 2011
Your variables hint at "first row" to "last column" which doesn't sound right. A renaming might be in order.
Now, provided that lc1 and N have been chosen to be on grid boundaries:
mat2cell(img(fc1:N+21,fr1:lc1+31), 21 * ones(1,1+(N-fc1)/21), 31 * ones(1,1+(lc1-fr1)/31))
Siddharth Mallya
Siddharth Mallya el 15 de Abr. de 2011
Thank you so much Walter ! You've been a great help to me .. :)

Iniciar sesión para comentar.

Más respuestas (1)

Pedro Serra
Pedro Serra el 24 de Mzo. de 2011

0 votos

An answer to this question would be really nice. I'm dealing with the same issue:
I have an image upon which I've drawn a grid. I now would like to understand how can I extract individual areas of the grid?
(My final goal is to color specific areas of that grid)
Thanks in advance!

1 comentario

Siddharth Mallya
Siddharth Mallya el 25 de Mzo. de 2011
Well, one way I am thinking now is to crop the image in a for loop .. But i think the computational complexity increasing in this .. So ya, are there any boundary detection algorithm like flood fill with a seed point ?

Iniciar sesión para comentar.

Categorías

Más información sobre Graphics Performance en Centro de ayuda y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by