How to convert 1D binary data matrix to 2D image matrix?
Ältere Kommentare anzeigen
I have a one-dimensional matrix of size 256X256X8. It has a string of 0 and 1 of the said length. I want to form an 2D Image matrix of size 256x256 from the previous matrix with each eight bits in the original matrix representing an integer in the final matrix. Is there any way to do it?
Akzeptierte Antwort
Weitere Antworten (1)
Azzi Abdelmalek
am 4 Jan. 2013
[ii,jj]=find(ones(256,256));
a=randi(2,256,256,8)-1;
b=cell2mat(arrayfun(@(x,y) a(x,y,1:8),ii,jj,'un',0)' );
out=bin2dec(num2str(reshape(b,256*256,8)));
res=zeros(256,256);
res(1:256*256)=out
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!