Joining matrices into 1 matrix?
16 次查看(过去 30 天)
显示 更早的评论
D = imread('peppers.png');
D = double(D)/255; %convert class and normalize Y
ycbcrmap = rgb2ycbcr(D); %Convert the image to YCbCr colour space
Y = ycbcrmap(:,:,1); % Y channel
Cb = ycbcrmap(:,:,2); % Cb channel
Cr = ycbcrmap(:,:,3); % Cr channel
%On Y
E0 = dct2(Y); %perform the 2-D DCT
[rows,columns,dim] = size (E0);
sz2 = [rows, columns];
%%Spilliting image into a cell array
chunk_size2 = [8 8]; % your desired size of the chunks image is broken into
sc2 = sz2 ./ chunk_size2; % number of chunks in each dimension; must be integer
% split to chunk_size(1) by chunk_size(2) chunks
X2 = mat2cell(E0, chunk_size2(1) * ones(sc2(1),1), chunk_size2(2) *ones(sc2(2),1));
[r, c] = size(X2);
%inv_X2 = cell2mat(X2);
for row = 1 : r
for col = 1 : c
Z = cell2mat(X2(row, col));
end
end
As it stands Z is only showing the last matrix of the cell X2. How can I join all the matrices of Z to reform the image in the same size of image D?
0 个评论
采纳的回答
KSSV
2017-5-17
D = imread('peppers.png');
D = double(D)/255; %convert class and normalize Y
ycbcrmap = rgb2ycbcr(D); %Convert the image to YCbCr colour space
Y = ycbcrmap(:,:,1); % Y channel
Cb = ycbcrmap(:,:,2); % Cb channel
Cr = ycbcrmap(:,:,3); % Cr channel
%On Y
E0 = dct2(Y); %perform the 2-D DCT
[rows,columns,dim] = size (E0);
sz2 = [rows, columns];
%%Spilliting image into a cell array
chunk_size2 = [8 8]; % your desired size of the chunks image is broken into
sc2 = sz2 ./ chunk_size2; % number of chunks in each dimension; must be integer
% split to chunk_size(1) by chunk_size(2) chunks
X2 = mat2cell(E0, chunk_size2(1) * ones(sc2(1),1), chunk_size2(2) *ones(sc2(2),1));
[r, c] = size(X2);
%inv_X2 = cell2mat(X2);
Z = cell(r,c) ;
for row = 1 : r
for col = 1 : c
Z{row,col} = cell2mat(X2(row, col));
end
end
Z = cell2mat(Z) ;
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Computational Geometry 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!