Image as a string of binary numbers

1 view (last 30 days)
Hunter Thurmond
Hunter Thurmond on 3 Mar 2014
Commented: Walter Roberson on 5 Mar 2014
Is there a way to convert a .jpg or .gif into a string of binary numbers?
I want to have a string of binary numbers that could be copied from a word document then read back in MATLab as a picture.
I would also need to know what function could such a string as an image.

Answers (1)

Walter Roberson
Walter Roberson on 3 Mar 2014
Converting to text:
dec2bin(TheImage,8)
Converting back:
reshape(uint8(bin2dec(TheStringArray)), size(TheImage))
  4 Comments
Walter Roberson
Walter Roberson on 5 Mar 2014
? I did give the "to text" and "back" code ?
Walter Roberson
Walter Roberson on 5 Mar 2014
Hunter: use reshape() to change it into a vector. Just be sure to reshape() back the right way!

Sign in to comment.

Categories

Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!