MATLAB Answers

user06
0

how to convert an image into bits???

Asked by user06
on 24 Feb 2015
Latest activity Commented on by Walter Roberson
on 14 Mar 2017
how we can convert an image into bits ?? and that bits back to image?

  2 Comments

A relatively simple solution (since what you want is quite definitely not obvious) is to scan it, then print the scanned 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.

2 Answers

Answer by 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))

  11 Comments

B: Cannot display variables with more than 524288 elements.
C: is displaying the binary stream
D: Cannot display variables with more than 524288 elements.
I: is working
I_out: working
Dear Shoaibur Rahman, Ur code is usefull for me.
My purpose is search the Binary-pattern into binary stream of color image, then I want to implement the concept of Steganography for my research.
Please please provide me the code to search the binary-pattern into file of binary-stream of Colored image,
Please help me, how to solve given problem
B: Cannot display variables with more than 524288 elements.
D: Cannot display variables with more than 524288 elements.
In MATLAB variables values are not displayed of following variables
B: Cannot display variables with more than 524288 elements.
C: is displaying the binary stream
D: Cannot display variables with more than 524288 elements
so Binary stream could not be displayed, please help me
524288 elements is 512 x 1024. If you were to display more than that many elements at the same time, you would be devoting an average of less than 2 pixels each to them. At that point you should be considering using imagesc() to display the array.
You cannot get around the 524288 limit; it is built-in to MATLAB. If you need to use the variable browser to look at part of the array, then extract a portion of the array that is no more than 512 x 1024 (or 1024 x 512) and assign it to a variable and view that variable.
Or just disp() the entire array.

Sign in to comment.


Answer by Image Analyst
on 24 Feb 2015

It's already in bits, as are all numbers in computers.

  6 Comments

See my attached demo for copying and pasting an image or portion of an image that you specify into a bigger image.
Please describe what you want. No one can figure it out. I just gave you code to do copying and pasting. Is that what "insert the image bits into different image" means? Who knows? Only you. Or perhaps you mean watermarking or steganography, though you didn't add any tag for those concepts so I have my doubts. But your imprecise language leaves them as possibilities. Will you clear up exactly what you want? I have a demo for LSB Steganography if that's what you want, but I have hundreds of demos and I can't post them all, so let me know if you're working on steganography.
user06
on 26 Feb 2015
actually i m working on watermarking.and i need to process each and every pixel of image. and according to the pixel value (whether 0 or 1) i need to take appropriate action.

Sign in to comment.