Joining matrices into 1 matrix?

3 views (last 30 days)
CharlesB
CharlesB on 17 May 2017
Commented: CharlesB on 17 May 2017
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?

Accepted Answer

KSSV
KSSV on 17 May 2017
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) ;

More Answers (0)

Categories

Find more on Computational Geometry in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!