how can i combine the binary values in a single cell of a uint8 matrix?
2 次查看(过去 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!