Recombine cell arrays to produce a new image

1 次查看(过去 30 天)
Hi, I've split an image into blocks
for testing ive skipped all odd blocks
now how to i recombine all cells to create the a new picture with all the cells
plotIndex = 1;
numPlotsR = size(Cellarray, 1);
numPlotsC = size(Cellarray, 2);
for r = 1 : numPlotsR
for c = 1 : numPlotsC
if bitget(c,1)
fprintf('plotindex = %d, c=%d, r=%d\n', plotIndex, c, r);
else
fprintf('noooooo\n')
end
% Plot consecutively.
if bitget(c,1)
subplot(numPlotsR, numPlotsC, plotIndex);
plotIndex = plotIndex +1
continue;
end
% Extract the numerical array out of the cell
rgbBlock = Cellarray{r,c};
imshow(rgbBlock); % Could call imshow(ca{r,c})
[rowsB, columnsB, numberOfColorBandsB] = size(rgbBlock);
caption = sprintf('B#%d/%d', ...
plotIndex, numPlotsR*numPlotsC);
title(caption);
drawnow;
% Increment the subplot to the next location.
plotIndex = plotIndex + 1;
end
end
  2 个评论
Image Analyst
Image Analyst 2020-12-7
What is Cellarray? You forgot to include the first part of your program!
To properly indent your code, back in MATLAB (not here), type control-a (to select all) then type control-i (to properly indent). Now you can copy and paste the code here and not have it look like a total mess.
Saud Alfalasi
Saud Alfalasi 2020-12-8
I = imread('hide.jpg');
[rows, columns, planes] = size(I);
blockSizeR = 50; % Rows in block.
blockSizeC = 50; % Columns in block.
FullBlockRows = floor(rows / blockSizeR);
blockVectorR = [blockSizeR * ones(1, FullBlockRows), rem(rows, blockSizeR)];
% Figure out the size of each block in columns.
FullBlockColums = floor(columns / blockSizeC);
blockVectorC = [blockSizeC * ones(1, FullBlockColums), rem(columns, blockSizeC)];
% Create the cell array
Cellarray = mat2cell(I, blockVectorR, blockVectorC, planes);
% Display all the blocks.
count =1;
plotIndex = 1;
numPlotsR = size(Cellarray, 1);
numPlotsC = size(Cellarray, 2);
for r = 1 : numPlotsR
for c = 1 : numPlotsC
if bitget(c,1)
fprintf('plotindex = %d, c=%d, r=%d\n', plotIndex, c, r);
else
fprintf('noooooo you odd bitch\n')
end
% Plot consecutively.
if bitget(c,1)
subplot(numPlotsR, numPlotsC, plotIndex);
plotIndex = plotIndex +1
continue;
end
% Extract the numerical array out of the cell
rgbBlock = Cellarray{r,c};
%count = count+1
%newimage = +rgbBlock
imshow(rgbBlock);% Could call imshow(ca{r,c})
[rowsB, columnsB, numberOfColorBandsB] = size(rgbBlock);
caption = sprintf('B#%d/%d', ...
plotIndex, numPlotsR*numPlotsC);
title(caption);
drawnow;
% Increment the subplot to the next location.
plotIndex = plotIndex + 1;
end
end
%figure
%imshow(newimage)

请先登录,再进行评论。

回答(1 个)

KALYAN ACHARJYA
KALYAN ACHARJYA 2020-11-30
编辑:KALYAN ACHARJYA 2020-11-30
"now how to i recombine all cells to create the a new picture with all the cells"
cell2mat
  1 个评论
Saud Alfalasi
Saud Alfalasi 2020-12-7
Hi Kalyan, it's not working
F=cell2mat(rgbBlock);
imshow(F)
Brace indexing is not supported for variables of this type.
Error in cell2mat (line 42)
cellclass = class(c{1});
Error in blocktest (line 47)
F=cell2mat(rgbBlock);

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Red 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by