Dividing images into blocks

I`ve loaded a video. Then i divided the video into individual frames. Now i want to divide each frame into a group of blocks. After dividing them into blocks, i want to compare the blocks of one frame with the blocks of another frame, to know whether they are matching.
1. How to divide frame into blocks? 2. How to read the blocks(pixel values of the frames)? 3. How to compare the blocks?

1 comentario

Vignesh
Vignesh el 3 de Mzo. de 2012
Movida: DGM el 29 de Dic. de 2023
How to find the motion vector of a macroblock?

Iniciar sesión para comentar.

Respuestas (2)

Sean de Wolski
Sean de Wolski el 28 de Feb. de 2012

1 voto

perhaps mat2cell(), blockproc() or a double for-loop.

5 comentarios

Vignesh
Vignesh el 28 de Feb. de 2012
Movida: DGM el 29 de Dic. de 2023
I used mat2cell function.
>> i=imread('D:\\Frames\\image1.jpg');
>> a=240;
>> b=320;
>> g=mat2cell(i,[a a],[b b],3);
>> g
g =
[240x320x3 uint8] [240x320x3 uint8]
[240x320x3 uint8] [240x320x3 uint8]
So, in g, do i have 4 blocks of that image, now? If i want to see the image of these individual blocks , how to see them? Pls help...
Sean de Wolski
Sean de Wolski el 28 de Feb. de 2012
Movida: DGM el 29 de Dic. de 2023
imshow(G{1,1}) %show first block
Vignesh
Vignesh el 28 de Feb. de 2012
Movida: DGM el 29 de Dic. de 2023
Thanks frd.. I could seperate a single frame into blocks now. But i`m not able to get all the frames, divided into blocks. I used the below syntax.
>> for j=1:n
i=imread('D:\\Frames\\image%d.jpg',j);
g[j]=mat2cell(i,[a a],[b b],3);
??? g[j]=mat2cell(i,[a a],[b b],3);
|
Error: Unbalanced or unexpected parenthesis or bracket.
Sean de Wolski
Sean de Wolski el 28 de Feb. de 2012
Movida: DGM el 29 de Dic. de 2023
g(i) or g{i} for a cell array. g[i] is not a valid syntax in MATLAB.
Vignesh
Vignesh el 1 de Mzo. de 2012
Movida: DGM el 29 de Dic. de 2023
I managed to divide all the frames into blocks.. Now i`m trying to calculate the motion vectors of each block. For that, i need to find Mean Square error(MSE), which needs the location of each block(x,y). How to find the location of blocks? I tried my best to find it..

Iniciar sesión para comentar.

Image Analyst
Image Analyst el 28 de Feb. de 2012

1 voto

Depends on how you define blocks. Perhaps you want quadtree decomposition if you want blocks of variable size. It's in the Image Processing Toolbox.

Etiquetas

Preguntada:

el 28 de Feb. de 2012

Movida:

DGM
el 29 de Dic. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by