how can i combine the binary values in a single cell of a uint8 matrix?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Let i have read one image,say
a=imread('f.jpg');/*reading pixels*\
b=dec2bin(a)-'0';/*converting to double array *\
c=uint8(b);/*converting to integer array *\
when i do c(1), it shows 1/0(MSBbit).
what i want is, it should show the 8 bit binary number i.e c(1)=10000000(say the pixel is 128).
how to do.
0 commentaires
Réponses (1)
Guillaume
le 11 Nov 2016
c = reshape(str2double(cellstr(dec2bin(a))), size(a))
is the closest to what you want. Note that it will be completely useless if you then want to manipulate bits.
As said before, matlab does not have binary numbers. It's not a concept that exists. c(1)=10000000 will always mean the decimal 10 millions, never the decimal 128.
If you want to manipulate bits, you can do it straight on a, as I've said several times.
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!