>> im=imread('trees.tif');
>> im_new = my_histstretch(im);
>> figure(1);clf;colormap gray
>> subplot(221)
>> imshow(im)
>> title('Original image')
>> subplot(222)
>> imshow(im_new)
>> title('Result image')
>> subplot(223)
>> imhist(im)
>> title('Histogram')
>> subplot(224)
>> imhist(im_new)
>> title('Histogram')
Task 2. Histogram equalization
In this part of the lab the student is supposed to write a Matlab-function
that performs histogram equalization on an image. The function should have
the following initial lines:
function [im_out] = my_histeq(im_in,n);
% IM_OUT = MY_HISTEQ(IM_IN,N) transforms IM_IN to IM_OUT
% according to the histogram equalization method.
% N specifies the number of possible grayscale values in IM_IN,
% default value is 256.
% The values in IM_IN are assumed to be in the range of 0 255
...
Useful commands:
nargin to check if N is set to a value dierent to 256
hist creates an histogram of the image values. Please, note that this function
calculates an histogram of a vector. Therefore, use (:) to vectorize an image
matrix.
cumsum calculates the transformation function for a given histogram .
You are allowed to use other functions that you can nd in Matlab. Not
histeq :-)
http://www.go2album.com/pg/profile/chrisben
http://www.americanquarterly.org/index.php/member/61367/
http://www.protectthehuman.com/users/chrisben
http://www.indabamusic.com/people/328620832/
http://www.earthswoop.com/forums/member.php?u=36169
http://www.communityofsweden.com/members/profile/?user=53977
http://www.retrogamer.net/show_profile.php?username=chrisben
http://skirt.com/chrisben
Test your function on the image tire.tif
Task 3. Spatial ltering
Study the eect of dierent ltering, by writing, for example, the following
lines for a smoothing lter:
>> im = imread('saturn.tif');
>> mean_filter = ones(9,9); % change the size as you like...
>> mean_filter = mean_filter/numel(mean_filter);
>> filtered_im = imfilter(im,mean_filter);
>> figure(1);clf;colormap gray
>> subplot(121)
>> imshow(im)
>> title('Original image')
>> subplot(122)
>> imshow(filtered_im)
>> title('Smoothed image')
Repeat the exercise using a sharpening lter to enhance edges.
>> im_new = my_histstretch(im);
>> figure(1);clf;colormap gray
>> subplot(221)
>> imshow(im)
>> title('Original image')
>> subplot(222)
>> imshow(im_new)
>> title('Result image')
>> subplot(223)
>> imhist(im)
>> title('Histogram')
>> subplot(224)
>> imhist(im_new)
>> title('Histogram')
Task 2. Histogram equalization
In this part of the lab the student is supposed to write a Matlab-function
that performs histogram equalization on an image. The function should have
the following initial lines:
function [im_out] = my_histeq(im_in,n);
% IM_OUT = MY_HISTEQ(IM_IN,N) transforms IM_IN to IM_OUT
% according to the histogram equalization method.
% N specifies the number of possible grayscale values in IM_IN,
% default value is 256.
% The values in IM_IN are assumed to be in the range of 0 255
...
Useful commands:
nargin to check if N is set to a value dierent to 256
hist creates an histogram of the image values. Please, note that this function
calculates an histogram of a vector. Therefore, use (:) to vectorize an image
matrix.
cumsum calculates the transformation function for a given histogram .
You are allowed to use other functions that you can nd in Matlab. Not
histeq :-)
http://www.go2album.com/pg/profile/chrisben
http://www.americanquarterly.org/index.php/member/61367/
http://www.protectthehuman.com/users/chrisben
http://www.indabamusic.com/people/328620832/
http://www.earthswoop.com/forums/member.php?u=36169
http://www.communityofsweden.com/members/profile/?user=53977
http://www.retrogamer.net/show_profile.php?username=chrisben
http://skirt.com/chrisben
Test your function on the image tire.tif
Task 3. Spatial ltering
Study the eect of dierent ltering, by writing, for example, the following
lines for a smoothing lter:
>> im = imread('saturn.tif');
>> mean_filter = ones(9,9); % change the size as you like...
>> mean_filter = mean_filter/numel(mean_filter);
>> filtered_im = imfilter(im,mean_filter);
>> figure(1);clf;colormap gray
>> subplot(121)
>> imshow(im)
>> title('Original image')
>> subplot(122)
>> imshow(filtered_im)
>> title('Smoothed image')
Repeat the exercise using a sharpening lter to enhance edges.
No comments:
Post a Comment