storing values of iteration in loop with varying rows and columns
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Ayesha
am 6 Mai 2014
Beantwortet: Image Analyst
am 6 Mai 2014
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 Kommentare
Akzeptierte Antwort
Image Analyst
am 6 Mai 2014
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Lighting, Transparency, and Shading finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!