i am trying to divide a RGB image into 4*4 block.below program is not running.
Show older comments
the program is
function pd_repmt=repmat(n,d,k)
img=imread('F:\Images.jpg', 'jpg');
s=size(img);
%block calculation
n=4; %block size
bs=[n n n];
nb=s./bs;
a_bl=mat2cell(img,repmat(bs(1),1,nb(1)),repmat(bs(2),1,nb(2)));
celldisp(a_bl);
pd_repmt=a_bl;
end
it is givving this error
Maximum recursion limit of 500 reached. Use
set(0,'RecursionLimit',N)
to change the limit. Be aware that exceeding your available stack space can
crash MATLAB and/or your computer.
Error in ==> imformats>find_in_registry
or
Error using ==> rdivide
Matrix dimensions must agree.
Error in ==> repmat at 7
nb=s./bs;
how to correct it??
3 Comments
Walter Roberson
on 6 May 2015
Joseph, you should move what you wrote to an Answer, as you have correctly identified the problem.
Joseph Cheng
on 6 May 2015
Edited: Joseph Cheng
on 6 May 2015
did i? I try to keep things as comments unless i test out the problem or have a really good explanation. I didn't have the time at the moment to fully debug it but saw a clear issue if the code was able to run 1 step further. Besides who does it for the points anyways its disheartening to even attempt to catch up. Only foreseeable way is to start answering people's homework for the number of doitforme questions.
Walter Roberson
on 6 May 2015
By making your comment into an answer, it can be Accepted, which marks the question as solved.
Accepted Answer
More Answers (1)
Image Analyst
on 6 May 2015
0 votes
Try some code that works, like the two samples in the FAQ for dividing your image into blocks. http://matlab.wikia.com/wiki/FAQ#How_do_I_split_an_image_into_non-overlapping_blocks.3F
If you want to process the blocks as you move along, then you'd be best off calling blockproc(). I can attach examples of blockproc() if you request them.
Categories
Find more on Neighborhood and Block Processing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!