Quantcast
Viewing all articles
Browse latest Browse all 368

Color to Grayscale Conversion: MATLAB Image Processing Tutorial

Hi friends, this is my first tutorial on Matlab image processing .The purpose of this tutorial is to gain familiarity with MATLAB’s Image Processing Toolbox. Let us start the basic of image processing with a very simple example i.e. converting a color image of any format (ex. jpeg,jpg,bmp,etc) into a grayscale image.

MATLAB Program for Color to Grayscale Conversion

Step 1:

Initially you have to define a matrix A with a path of the image that you have to convert. For this purpose if you cant copy a path of the image file, just install this small software (http://www.novell.com/coolsolutions/tools/downloads/pathc400.zip) after installing this software simply right click on image you will see an option for copy long url. OK after copying the image path.

Step 2:

Define matrix B with the image format. In this case jpg. You can change the format you have.

Step 3:

C=rgb2gray(B).   Here rgb stands for RedGreenBlue i.e. color image gray stands for converting it into grayscale.

%tutorial M-file
%created by : myclassbook.org
%created on : 20 may 2013

% Load a color .jpg image and convert it into grayscale

A=’H:New photoImagesPhoto1619.jpg’; %designate matrix A as the spcified file
B=imread(A,’jpg’)                            %matrix B loaded with jpg file specified by A
figure (1),imshow(B);                     %show image B in figure window 1
C=rgb2gray(B)                                 %convert color image to grayscale image
figure (2),imshow(C);                    %show image C in figure window 2

Image may be NSFW.
Clik here to view.
MATLAB Image Processing
MATLAB Image Processing
Image may be NSFW.
Clik here to view.
MATLAB Image Processing
MATLAB Image Processing
Image may be NSFW.
Clik here to view.
MATLAB Image Processing
MATLAB Image Processing

If you like this article, please share it with your friends and like or facebook page for future updates. Subscribe to our newsletter to get notifications about our updates via email. If you have any queries, feel free to ask in the comments section below. Have a nice day!

The post Color to Grayscale Conversion: MATLAB Image Processing Tutorial appeared first on MyClassBook.


Viewing all articles
Browse latest Browse all 368

Trending Articles