how to divide an image into blocks

1 次查看(过去 30 天)
Pat
Pat 2011-9-12
how to divide an image into blocks of size 10*10,can anyone help please

回答(2 个)

Junaid
Junaid 2011-12-11
Dear Pat,
mat2cell is the only easy solution for your question. You are getting this error because your the mod of your IMG and 10 is not equal to zero. In other words the dimensions of IMG can't be evenly divided by 10. so either you take image of size whose dimensions are divisible by 10. Example:
IMG = magic(100);
IMGcells = mat2cell(IMG, 10*ones(1,size(IMG,1)/10), 10*ones(1,size(IMG,2)/10));
so make sure your image dimensions are divisible by 10, or any grid size you want.

Walter Roberson
Walter Roberson 2011-9-12
IMGcells = mat2cell(IMG, 10*ones(1,size(IMG,1)/10), 10*ones(1,size(IMG,2)/10);
  1 个评论
Pat
Pat 2011-9-12
I TRIED BUT I GET AN ERROR ,CAN U HELP
Error using ==> mat2cell at 116
Input arguments, D1 through D2, must
sum to each dimension of the input
matrix size, [256 256].
Error in ==> fp3 at 2
IMGcells = mat2cell(IMG,
10*ones(1,size(IMG,1)/10),
10*ones(1,size(IMG,2)/10))

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Computer Vision with Simulink 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by