How can I merge 4*4 cell arrays to form a 256*256 cell array?

조회 수: 3 (최근 30일)
SMRITI
SMRITI 2015년 9월 21일
답변: Matt J 2015년 9월 22일
Actually I took a plaintext image,converted that to 8 bit binary and then did DNA mapping. After that i splitted that into 4*4 cell arrays(each element of that cell looks like 'ATCG' or something ) and did some operation. Now I want to merge all those cells to get the final 256*256 cell?
  댓글 수: 5
SMRITI
SMRITI 2015년 9월 22일
편집: Walter Roberson 2015년 9월 22일
a=imread('cameraman.tif');
%converting decimal matrix to binary
for i=1:1:256
for j=1:1:256
b{i,j,1} = dec2bin(a1(i,j),8);
end
end
%disp(b)
%DNA coding of plaintext image
plaintext_dna = bin2DNA(b);
size(plaintext_dna);
%----------------------------------------------------------
%STEP 2:
%DIVIDE PLAINTEXT DNA INTO SMALL BLOCKS OF 4*4
%---------------------------------------------------------
K=4;
c=K*ones(256/4, 1);
small_mat=mat2cell(plaintext_dna,c',c');
%size(small_mat);
%______________
%NOW I WANT TO MERGE small_mat to get back plaintext_dna........
SMRITI
SMRITI 2015년 9월 22일
편집: Walter Roberson 2015년 9월 22일
function [ DNA_matrix] = bin2DNA( bin_matrix )
codebook = containers.Map({'00','11','10','01'},{'A','T','G','C'}); %// Lookup
outputCell = cellfun(@(x) values(codebook, {x(1:2),x(3:4),x(5:6),x(7:8)}), ...
bin_matrix, 'uni', 0);
DNA_matrix = cellfun(@cell2mat, outputCell, 'uni', 0);
end

댓글을 달려면 로그인하십시오.

답변 (2개)

Walter Roberson
Walter Roberson 2015년 9월 22일
cell256 = [small_mat1{1}, small_mat1{3}; small_mat1{2}; small_mat1{4}];

Matt J
Matt J 2015년 9월 22일
C=arrayfun(@(i) vertcat(small_mat{:,i}),1:64,'uni',0);
merged=[C{:}];

카테고리

Help CenterFile Exchange에서 Import, Export, and Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by