storing values of iteration in loop with varying rows and columns

조회 수: 1 (최근 30일)
Ayesha
Ayesha 2014년 5월 6일
답변: Image Analyst 2014년 5월 6일
I'm having a for loop where operation is being performed on every image block. This image block has varying rows and columns at every iteration. For instance, for the first five iterations, the output row and column are 50x50. But for sixth iteration the dimension changes to 50x14. I am able to store first five image blocks in loop but its giving me an error for the sixth image block. Here's the code:
i = 1;
numPlotsR = size(ca, 1);
numPlotsC = size(ca, 2);
for r = 1 : numR
for c = 1 : numC
subplot(numR, numC, i);
rgbBlock = ca{r,c};
imshow(rgbBlock,[]);
[rowsB columnsB numberOfColorBandsB] = size(rgbBlock);
itLoop(rowsB,columnsB,i)=rgbBlock; % this is where I want to store image block values for each iteration
i = i + 1;
end
end
What do you suggest?

채택된 답변

Image Analyst
Image Analyst 2014년 5월 6일
I suggest not doing that. First of all rgbBlock is already stored in the ca cell array. It's in the cell at row r, column c, so why do you want to store it again.
Secondly, your itLoop line won't work because rgbBlock is a numerical array, not a cell like you'd get from ca(r,c), and you can't store a 3D image array into a single element at the last row and column of itLoop. I can tell you how to fix it, but I won't because I don't recommend what you're asking to do for the first reason I said.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by