Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
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 Kommentare
Joseph Cheng
Joseph Cheng am 6 Mai 2015
Bearbeitet: Joseph Cheng am 6 Mai 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
Walter Roberson am 6 Mai 2015
By making your comment into an answer, it can be Accepted, which marks the question as solved.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Joseph Cheng
Joseph Cheng am 6 Mai 2015
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 Kommentare
pritha Das
pritha Das am 7 Mai 2015
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 am 8 Mai 2015
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Image Analyst
Image Analyst am 6 Mai 2015
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.

Community Treasure Hunt

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

Start Hunting!

Translated by