Professional Documents
Culture Documents
Spatial Transforms
Note:
Save all your work in different M-files. You will have to show the all the work and
processing at time of evaluation. Homework and any pending tasks have to be submitted no
later than Monday 4:00PM sharp.
Objectives:
When you resize an image, you specify the image to be resized and the magnification factor. To
enlarge an image, specify a magnification factor greater than 1. To reduce an image, specify a
magnification factor between 0 and 1.
Task 1: (1 Mark)
I = imread('circuit.tif');
J = imresize(I,[100 150]);
imshow(I)
figure, imshow(J)
Task 2: (1 Mark)
1. Now use another variant of the imresize function and repeat the above tasks.
J = imresize(I,[100 150]);
When you rotate an image, you specify the image to be rotated and the rotation angle, in degrees.
If you specify a positive rotation angle, imrotate rotates the image counterclockwise; if you
specify a negative rotation angle, imrotate rotates the image clockwise
Task 3: (1 Mark)
J = imrotate(I,35);
To extract a rectangular portion of an image, use the imcrop function. Using imcrop, you can
specify the crop region interactively using the mouse or programmatically by specifying the
size and position of the crop region.
Task 4: (1 Mark)
I = imread('circuit.tif')
J = imcrop(I);
Imshow(J);
Task 5: (1 Mark)
1. Now crop an image by specifying the rectangular part you need to capture.
I = imread('circuit.tif')
J = imcrop(I,[60 40 100 90]);
Imshow(J);
4.4: Histogram Equalization
The function imhist(I) displays a histogram for the intensity image I above a grayscale colorbar.
The number of bins in the histogram is specified by the image type. If I is a grayscale image,
imhist uses a default value of 256 bins. If I is a binary image, imhist uses 2 bins.
Task 6: (1 Mark)
I = imread('pout.tif');
imhist(I)
You can either use the function imcomplement to get the photographic negative of an image or
use the transformation: s = L – 1 – r.
Task 7: (1 Mark)
orig = imread('blurry_moon.tif');
subplot(2,2,1)
imshow(orig);
title('Original Image');
a = imread('cameraman.tif');
subplot(2,2,1)
imshow(a);
subplot(2,2,2)
imhist(a)
flood_eq = imadjust(a , [0 0.12], [0.6 1.0]);
subplot(2,2,3)
imshow(flood_eq);
subplot(2,2,4)
imhist(flood_eq);
Imadjust can also accept an additional argument that specifies the gamma correction factor.
Depending on the value of gamma, the mapping between values in the input and output images
might be nonlinear. Gamma can be any value between 0 and infinity. If gamma is 1 (the default),
the mapping is linear. If gamma is less than 1, the mapping is weighted toward higher (brighter)
output values. If gamma is greater than 1, the mapping is weighted toward lower (darker) output
values.
Task 9: (3 Marks)
b = imadjust(orig,[],[],3);
subplot(2,2,2)
imshow(b);
title('Gamama = 3');