storing values of iteration in loop with varying rows and columns
1 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!