Image Processing Using Matlab: Practical 1
Image Processing Using Matlab: Practical 1
Practical 1
Read and Display an Image
close all
This command clears the MATLAB workspace
of any variables and close open figure
windows.
I = imread('pout.tif');
This command reads one of the sample images
included with the toolbox, pout.tif, and stores
it in an array named I. pout.tif is a grayscale
image.
Read and Display an Image
imshow(I)
This command is used to display an image.
See different functions in figure window:
Go to axis properties in edit. Figure will open with
axis window. Check functions of different options
available in axis prop.
whos
This command gives information about variables in
the workspace
Adjusting Image Contrast Using the
Adjust Contrast Tool
Imtool command
imtool('pout.tif')
This command is used to View an image in the
Image Tool
In this window, use adjust contrast button to
change contrast of the image.
Change min , max, width and centre in the
adjust contrast window and see its effect on
the image.
Adjust contrast
See effect of other tools on the image
Navigate function
Inspect pixel value
Measure distance
Display image information
Adjust contrast
Crop image
Zoom in
Zoom out
Adjust contrast
Drag image to pan
Adjust contrast/brightness via mouse motion
Choose colormap
Imcontrast command
imshow('pout.tif')
imcontrast(gca)
imadjust command
I = imread('pout.tif');
J = imadjust(I);
imshow(I), figure, imshow(J)
Command figure is used to prevent overlapping
of 2nd image over 1st image.
Improve image contrast
I = imread('pout.tif');
imshow(I)
figure, imhist(I)
I2 = histeq(I);
figure, imshow(I2)
Write the Image to a Disk File
imwrite (I2, 'pout2.png');
To see what imwrite wrote to the disk file, use
the imfinfo function.
imfinfo('pout2.png')