フィルターのクリア

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