Joining matrices into 1 matrix?

3 ビュー (過去 30 日間)
CharlesB
CharlesB 2017 年 5 月 17 日
コメント済み: CharlesB 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);
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?

採用された回答

KSSV
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) ;
  1 件のコメント
CharlesB
CharlesB 2017 年 5 月 17 日
Perfect! As i wanted :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeComputational Geometry についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by