Joining matrices into 1 matrix?

조회 수: 10 (최근 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 CenterFile Exchange에서 Computational Geometry에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by