Image Processing in MATLAB 9.3
Image Processing in MATLAB 9.3
ABSTRACT
In this paper we introduce how to handle different in MATLAB 9.3, there are many things to keep in
kinds of image formats in MATLAB 9.3 by using mind such as loading an image, using the right format,
Matlab Workspace & its Various Commands. Also we saving the data as different data types, how to display
illustrated example of processing the images
images. an image, conversion between different image
formats, etc. This worksheet presents some of the
Keywords: Image Processing, Image Formats, commands
mmands designed for these operations. Most of
reading Images these commands require you to have the Image
processing tool box installed with MATLAB 9.3. To
find out if it is installing, type ver at the MATLAB
Introduction 9.3 prompt. This gives you a list of what tool boxes
that are installed on your system.
This worksheet is an introduction on how to handle
images in MATLAB 9.3. When working with images
For further reference on image handling in MATLAB Image processing tool box that you can access via
9.3 you are recommended to use MATLAB 9.3's help MATLAB 9.3's help browser.
browser. There is an extensive on-line
line manual for the
@ IJTSRD | Available Online @ www.ijtsrd.com | Volume – 2 | Issue – 2 | Jan-Feb 2018 Page: 926
International Journal of Trend in Scientific Research and Development (IJTSRD) ISSN: 2456-6470
image format. Each matrix corresponds to one of the imaging later on in this course, you may use this
colors red, green or blue and gives an instruction of format.
how much of each of these colors a certain pixel
should use. How to convert between different formats
The command mat2gray is useful if you have a matrix that we can, for example, post the processed image on
representing an image but the values representing the the web. This is done using the imread and imwrite
gray scale range between, let's say, 0 and 1000. The commands. These commands require the Image
command mat2gray automatically re scales all entries processing tool box!
so that they fall within 0 and 255 (if you use the uint8
class) or 0 and 1 (if you use the double class). Reading and writing image files
@ IJTSRD | Available Online @ www.ijtsrd.com | Volume – 2 | Issue – 2 | Jan-Feb 2018 Page: 927
International Journal of Trend in Scientific Research and Development (IJTSRD) ISSN: 2456-6470
support the formats given in the section "Image Now open Matla and make sure you are in the same
formats supported by MATLAB 9.3" above. directory as your stored file. (You can check what
files your directory contains by typing ls at the
MATLAB 9.3 prompt. You change directory using
Loading and saving variables in MATLAB 9.3 the command cd.) Now type in the following
commands and see what each command does. (Of
This section explains how to load and save variables course, you do not have to type in the comments
in MATLAB 9.3. Once you have read a file, you given in the code after the % signs.)
probably convert it into an intensity image (a matrix)
and work with this matrix. Once you are done you I=imread('cell1.jpg'); % Load the image file and store
may want to save the matrix representing the image in it as the variable I.
order to continue to work with this matrix at another whos % Type "whos" in order to find out the size and
time. class of all stored variables.
save I % Save the variable I.
This is easily done using the commands save and
ls % List the files in your directory.
load. Note that save and load are commonly used
There should now be a file named "I.mat" in you
MATLAB 9.3 commands, and works independently
directory containing your variable I.
of what tool boxes that are installed.
Note that all variables that you save in MATLAB 9.3
Loading and saving variables
usually get the suffix .mat.
Operation MATLAB 9.3
Command Next we will see that we can display an image using
Save the Variable X. save x the command imshow. This command requires the
Load the Variable X load x image processing tool box. Commands for displaying
images will be explained in more detail in the section
Examples "How to display images in MATLAB 9.3" below.
In the first example we will down load an image from clear % Clear MATLAB 9.3's memory.
the web, read it into MATLAB 9.3, investigate its load I % Load the variable I that we saved above.
format and save the matrix representing the image. whos % Check that it was indeed loaded. imshow(I)
% Display the image
Example 1 I=im2double(I); % Convert the variable into double.
whos % Check that the variable indeed was converted
Down load the following image (by clicking on the
into double
image using the right mouse button) and save the file
% The next procedure cuts out the upper left
as cell1.jpg.
corner of the image
% and stores the reduced image as Ired.
for i=1:256
for j=1:256
Ired(i,j)=I(i,j);
end
end
whos % Check what variables you now have stored.
imshow(Ired) % Display the reduced image.
@ IJTSRD | Available Online @ www.ijtsrd.com | Volume – 2 | Issue – 2 | Jan-Feb 2018 Page: 928
International Journal of Trend in Scientific Research and Development (IJTSRD) ISSN: 2456-6470
Displaying an image given on matrix form Conclusion:
@ IJTSRD | Available Online @ www.ijtsrd.com | Volume – 2 | Issue – 2 | Jan-Feb 2018 Page: 929