How to divide an image in two blocks
Mostrar comentarios más antiguos
How can I divide an image into two halves? Then, after dividing it make each half independent, say
A = top half and
B = the bottom half.
So that I can extract features from each half.
2 comentarios
Nourou
el 8 de Ag. de 2014
Editada: Image Analyst
el 8 de Ag. de 2014
Hi Jack, Azzi,
Please I need a clarification about the usage of the following method:
im=imread('yourimage')
n=fix(size(im,1)/2)
A=im(1:n,:,:);
B=im(n+1:end,:,:)
imshow(A)
figure
imshow(B)
I try to use it on a grayscale image, but the results are 2 blank images. Please how can I edit your code to make it divide my image. I know you use it with a rgb image.
Thank you!


Image Analyst
el 8 de Ag. de 2014
Editada: Image Analyst
el 8 de Ag. de 2014
A and B are probably double for some reason. Try
imshow(A, []);
imshow(B, []);
Start your own question if you need more help.
And there is a FAQ for the original poster's question: http://matlab.wikia.com/wiki/FAQ#How_do_I_split_an_image_into_non-overlapping_blocks.3F
Respuesta aceptada
Más respuestas (1)
utkarsh kumar
el 26 de Abr. de 2019
0 votos
hi i am having a doubt in understanding the code.....in the below code
im=imread('yourimage')
n=fix(size(im,1)/2)
A=im(1:n,:,:);
B=im(n+1:end,:,:)
imshow(A)
figure
imshow(B)
What is the meaning of the highlighted one .
Thanks
1 comentario
Image Analyst
el 26 de Abr. de 2019
It says A is equal to rows 1 through n, all columns, all color rows. The colon means "all" if it's by itself, or "to" if it's in an expressions like 1:n.
So if n is the middle row, A will be the top half. Then B picks up from one row below the middle row. It says B equals all rows from one row below the middle row to the last row, and all columns and all color channels. If it's grayscale, having an extra : in there for the third index will not hurt - it will just ignore it.
Categorías
Más información sobre Image Arithmetic 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!