i am trying to divide a RGB image into 4*4 block.below program is not running.

조회 수: 1 (최근 30일)
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
Joseph Cheng
Joseph Cheng 2015년 5월 6일
편집: Joseph Cheng 2015년 5월 6일
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
Walter Roberson 2015년 5월 6일
By making your comment into an answer, it can be Accepted, which marks the question as solved.

댓글을 달려면 로그인하십시오.

채택된 답변

Joseph Cheng
Joseph Cheng 2015년 5월 6일
first off i would highly recommend that you do not call your function repmat() as it is already a matlab function. in the line a_bl= matcell() is the repmat that you're calling in the line the same repmat function that it resides? At this point it looks like its a call within a call within a call within a call within a call. Without running the function, it looks to be never ending loop.
However, put a breakpoint at line 7. See what the dimensions are.
  댓글 수: 2
pritha Das
pritha Das 2015년 5월 7일
thanks for answering my question...but still i am having a problem when i am running the program.. error is showing Matrix dimensions must agree. Error in ==> repmat at 7 nb=s./bs;
Walter Roberson
Walter Roberson 2015년 5월 8일
That tells me that you continued to call your routine "repmat". You need to rename it.
Your code is also attempting to divide into blocks of 4 along the color axis (RGB), the third dimension, but there are only 3 planes there.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2015년 5월 6일
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.

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by