converting binary image to gray scale image in Matlab

14,354

Solution 1

To convert a binary image of class logical to a grayscale image of class double, you simply call

double(yourBinaryImage)

EDIT

To revert from a binary image to the grayscale image you had before thresholding is impossible without the grayscale image, since by thresholding you have dropped all the grayscale texture information.

Solution 2

Maybe you can use the distance transform to achieve a gray scale image from a binary image. In MATLAB, try bwdist or something like that. The result, of course, will not be the original gray scale image.

Share:
14,354

Related videos on Youtube

Ofir A.
Author by

Ofir A.

Bachelor in Computer Science Passionate about programming.

Updated on June 04, 2022

Comments

  • Ofir A.
    Ofir A. almost 2 years

    I working on Optical Character Recognition system.

    I want to convert the license plate image from binary to gray scale.

    let's look at the next example:

    this is the binary image:

    enter image description here

    and this is the gray scale:

    enter image description here

    what I want to know is if there is a way to convert it from binary to the gray, or this is not possible because i've lost the information when I converted the picture to binary at the beginning.

    any idea how to do this? thanks

  • Jonas
    Jonas over 9 years
    @FarazAhmad: comments are not a good place to answer questions. Just hit the "ask a question" button next time. Anyway: Multiply the binary image by 255, and you're done (though depending on the class of the other grayscale image, you may have to convert to uint8 as well)
  • Raja Raghudeep Emani
    Raja Raghudeep Emani almost 7 years
    any thoughts on anti aliasing resampling done by yan le cunn to convert binary images to grayscale.

Related