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

1 visualización (últimos 30 días)
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 comentarios
Joseph Cheng
Joseph Cheng el 6 de Mayo de 2015
Editada: Joseph Cheng el 6 de Mayo de 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 el 6 de Mayo de 2015
By making your comment into an answer, it can be Accepted, which marks the question as solved.

Iniciar sesión para comentar.

Respuesta aceptada

Joseph Cheng
Joseph Cheng el 6 de Mayo de 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 comentarios
pritha Das
pritha Das el 7 de Mayo de 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 el 8 de Mayo de 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.

Iniciar sesión para comentar.

Más respuestas (1)

Image Analyst
Image Analyst el 6 de Mayo de 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.

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by