필터 지우기
필터 지우기

how can i combine the binary values in a single cell of a uint8 matrix?

조회 수: 1 (최근 30일)
aditya kumar sahu
aditya kumar sahu 2016년 11월 11일
답변: Guillaume 2016년 11월 11일
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.

답변 (1개)

Guillaume
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.

Community Treasure Hunt

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

Start Hunting!

Translated by