how can i combine the binary values in a single cell of a uint8 matrix?
조회 수: 3 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Guillaume
2016년 11월 11일
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
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!