divide an RGB image in to block of size 16*16
Show older comments
Hello,
I have an rgb image frame extracted from a video of size 240x320x3 , I am trying to make in to blocks of 16x16x3. The blocks will be used for analysis between different frames.
In my example i should have an array of 15x20 blocks, in which each block will have a 16x16x3 information.
as a first trail I made like 300(15*20 = 300) blocks Matlab shows busy and it never ends with the code I made. is this the way we do ? please suggest a way I can
I had seen examples with mat2cell but how to use it in 3d image ? here is my code
videoObject = VideoReader(Filename);
Im = read(videoObject,120);
[r,c,rgb] = size(Im);
Blocks = zeros(r/16,c/16,rgb,r*c);
for rc = 1:r*c
for row = 1:(r/16)
for col = 1:(c/16)
Blocks(1:16,1:16,:,rc) = Im(((16*(row-1))+1):(16*row),((16*(col-1))+1):(16*col),:);
end
end
end
Accepted Answer
More Answers (0)
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!