Friday, 21 July 2017

How to convert RGB image into binary

In this post, I am going to discuss about how to convert RGB or color map images into binary.

The following piece of code is used to convert RGB image to binary.


I=imread('1.jpg');
imshow(I);
binary=im2bw(I);

figure,imshow(binary);

In the above code, binary = im2bw(I) converts the truecolor image RGB to the binary intensity image . The im2bwfunction converts RGB images to binary in which their values lies between 0 and 1.

DESCRIPTION:


Read and display an RGB image, and then convert it to binary.
Read the sample file, 1.jpg, and display the RGB image.
I = imread('1.jpg');
    imshow(I);

Convert the RGB image to a binary image and display it.
binary=im2bw(I);
figure, imshow(binary);


No comments:

Post a Comment