I have converted a gray-scale image to binary using
im2bw() now i wanna do the opposite. How can I do that in MATLAB?
As you've stated the problem, you can't. Converting a grey-scale image to black and white (binary) you're comparing pixel values (0-256 for an 8-bit image) to a threshold (that you define) and giving each pixel a value of 1 if the pixel is above the threshold, and 0 if it's below the threshold. The binary image doesn't contain information about by how much the pixel value was above or below the threshold.
If you want to get the pixel values from the original image which are above the threshold, you can multiply the binary image and the original image. All the values in the original image below the threshold will be zeroed out when they are multiplied by the zeros in the binary image. All the pixel values above the threshold in the original value will be multiplied by one and will retain their original values.
Unfortunately, if you're given an arbitrary binary image with no information about the threshold used, or the original image, you cannot recover the original grey-scale values.
Hope this helps.
You have converted a matrix of integers into a two-valued map. It is not exactly invertible in general. An analogy: I am thinking of a bunch of numbers. If I tell you they are odd or even, can you guess them? Probably not.
However, under some conditions (image is not arbitrary, bounds are known), approximated reconstructions might be possible.
An example comes from compressive sensing, see for instance: 1-Bit Compressive Sensing.