how to convert an image in to binary bits sequence ?

Technical Source
2 min readAug 8, 2023

--

a=imread(‘cameramen.jpg’);

b= round(a./256);
but i got binary bits like this
1 0 1 0 0 1 0 0 0 0
0 0 0 1 0 1 0 1 0 0
.
.
.
   1 0 0 0 0 0 0 0 0 0 
0 1 0 1 0 1 0 1 0 0
.
.
1 0 1 0 1 0
0 0 0 0 0 0
but what i want is: b = (1 0 1 0 1 0 0 0 .....n)

NOTE:-

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help , Finance Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

You question is very unclear due to imprecise language.

Are you intending to binarise the image? That is convert each pixel to a single 0 or 1, as you’ve done with your b = round(a / 256), which convert all pixels below intensity 128 to 0 and all above 127 to 1. Or as your watermarking tag and question title suggest, convert each pixel to a sequence of bits?

If the latter, the best course is actually not to do it and use matlab’s bit wise operators. This will be much faster than converting to a matrix of bits and back.

Example, replace LSB of matrix with random 0 or 1:

SEE COMPLETE ANSWER CLICK THE LINK

--

--

Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.