how to convert an image into bits???

262 views (last 30 days)
user06 on 24 Feb 2015
Answered: Image Analyst on 25 Nov 2021 at 14:28
how we can convert an image into bits ?? and that bits back to image?
user06 on 25 Feb 2015
actually i want to insert the image bits into different image. so i need to convert the image into binary bits..

Sign in to comment.

Answers (3)

Shoaibur Rahman
Shoaibur Rahman on 24 Feb 2015
It is not clear to me exactly what is your goal? Are you trying to convert image pixels into binary bits? If so, you can use dec2bin for that, and bin2dec to get your image back.
I_in = your image...
% encoding image into array of bits
B = dec2bin(I_in);
C = reshape(B',1,numel(B)); % converted into bits
% decoding image from bits
D = reshape(C,size(B,2),size(B,1));
I_out = reshape(bin2dec(D'),size(I_in))
Walter Roberson
Walter Roberson on 25 Nov 2021 at 10:42 shows how.

Sign in to comment.

Image Analyst
Image Analyst on 24 Feb 2015
It's already in bits, as are all numbers in computers.
Image Analyst
Image Analyst on 30 Jun 2021
"actually i m working on watermarking"
See my atttached demo on Least significant bit watermarking.

Sign in to comment.

Image Analyst
Image Analyst on 25 Nov 2021 at 14:28
If you want to view bitplanes 0 through 7, as binary images, see my attached demo.

Community Treasure Hunt

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

Start Hunting!