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 Comment

Vignesh
Vignesh on 3 Mar 2012
Moved: DGM on 29 Dec 2023
How to find the motion vector of a macroblock?

Sign in to comment.

Answers (2)

Sean de Wolski
Sean de Wolski on 28 Feb 2012
perhaps mat2cell(), blockproc() or a double for-loop.

5 Comments

Vignesh
Vignesh on 28 Feb 2012
Moved: DGM on 29 Dec 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 on 28 Feb 2012
Moved: DGM on 29 Dec 2023
imshow(G{1,1}) %show first block
Vignesh
Vignesh on 28 Feb 2012
Moved: DGM on 29 Dec 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 on 28 Feb 2012
Moved: DGM on 29 Dec 2023
g(i) or g{i} for a cell array. g[i] is not a valid syntax in MATLAB.
Vignesh
Vignesh on 1 Mar 2012
Moved: DGM on 29 Dec 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..

Sign in to comment.

Image Analyst
Image Analyst on 28 Feb 2012
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.

Asked:

on 28 Feb 2012

Moved:

DGM
on 29 Dec 2023

Community Treasure Hunt

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

Start Hunting!