Академический Документы
Профессиональный Документы
Культура Документы
2014
INDEX
Sr.
No
Topic
1.
2.
3.
4.
Wavelet Analysis.
5.
6.
7.
Morphological Algorithms.
8.
Edge Detection.
9.
Image Segmentation.
10.
Region Filling.
11.
Morphological Operations.
12.
Logical Operations.
13.
14.
15.
Date
Page-No
Signature
IMAGE PROCESSING
2014
Practical No: 1
Topic: - Image Enhancement in Spatial Domain.
Problem Statement: Apply following image enhancement algorithms to the given input image. Display
the resulting image.
1. Contrast stretching: - Display dark, bright, low-contrast and high contrast
images by applying contrast stretching on an input image by manipulating the
mapped gray-levels in an input image.
2. Histogram Equalization: -Apply the histogram equalization technique on an
input image.
3. Image averaging: - Implement image averaging technique to remove the noise
from an image by using an averaging filter.
4. Smoothing: -Apply the smoothing effect to an input image by using appropriate
filter masks.
Used Functions Details: -
Prototype: IPTSETPREF(PREFNAME,VALUE)
Parameters:
o PREFNAME: Specified Preference.
o VALUE: Preference Value
3)
Parameters:
o
I: Input Image.
2
IMAGE PROCESSING
o
o
2014
'speckle'
Multiplicative
noise
Parameters:
o
I: Input Image
o
TYPE: Noise type.
IMAGE PROCESSING
2014
IMAGE PROCESSING
2014
IMAGE PROCESSING
2014
IMAGE PROCESSING
2014
Output: -
IMAGE PROCESSING
2014
Output: -
IMAGE PROCESSING
2014
Output: -
IMAGE PROCESSING
2014
Practical No: 2
Topic: - Image Enhancement in Frequency Domain.
Problem Statement: A filter function from one of the following filters along with a set of values
for the parameter list is provided. For this filter function derive the an (k x k)
filter mask for one of the values of k, k = 3,5,9. The filter mask is to be applied
to the given input image and the enhanced image is to be displayed.
1. Gaussian Low Pass Filter
2. Butterworth Low Pass Filter
3. Ideal High Pass Filter
4. Ideal Low Pass Filter
Used Functions Details:
1)
Function Name: butter
Prototype: [B,A] = BUTTER(N,Wn)
Description: It designs an Nth order lowpass digital Butterworth filter and
returns the filter coefficients in length N+1 vectors B (numerator) and A
(denominator).
Parameters:
o
N: Order of the filter
o
Wn: The cut-off frequency Wn must be between 0 < Wn < 1.0, with 1.0.
Function Name: fir1
Prototype: B = FIR1(N,Wn,X)
Description: It designs an N'th order X pass FIR digital filter.
Parameters:
o N: Order of the filter.
o Wn: The cut-off frequency Wn must be between 0 < Wn < 1.0, with
1.0.
o X: The value can be high or low to design highpass or lowpass filter
respectively.
10
IMAGE PROCESSING
2014
Output: -
11
IMAGE PROCESSING
2014
Output: -
12
IMAGE PROCESSING
2014
Output: -
13
IMAGE PROCESSING
2014
Output: -
14
IMAGE PROCESSING
2014
Practical No: 3
Topic: - Image Enhancement using Statistical Filters.
Problem Statement: The Statistical Filter specifications are provided. This filter should be
applied to the input image and the resulting image should be displayed
1. Mean and Median Filters
2. Max-min and Min-max Filters
15
IMAGE PROCESSING
2014
Output: -
16
IMAGE PROCESSING
2014
Output: -
17
IMAGE PROCESSING
2014
Output: -
18
IMAGE PROCESSING
2014
Practical No: 4
Topic: - Wavelet Analysis.
Problem Statement: A one dimensional function is input. This can be extracted from scan line
information of an image. A wavelet basis for one dimensional function should be
encoded. The function is displayed at different resolution levels, j = 4, 8, 16, 32.
(Wavelet Toolbox)
Used Functions Details: 1)
19
IMAGE PROCESSING
2014
20
IMAGE PROCESSING
2014
Output: -
21
IMAGE PROCESSING
2014
Practical No:
5
Topic: - Error Free Image Compression.
Problem Statement: An input image is provided. Any one of the following Error Free Image
Compression algorithm is provided. The algorithm is to be applied the input
image and percentage reduction along with the compressed image is to be
displayed. This image is now to be decompressed and the original image must
be displayed.
1. Variable length coding
2. Huffman coding
3. Lempel-Ziv-Welch (LZW) Coding
IMAGE PROCESSING
2014
23
IMAGE PROCESSING
2014
end
24
IMAGE PROCESSING
2014
Output: -
25
IMAGE PROCESSING
2014
Practical No:
6
Topic: - Lossy Image Compression.
Problem Statement: An input image is provided. A Lossy Image Compression algorithm is
provided. The algorithm is to be applied the input image and percentage
reduction along with the compressed image is to be displayed. The nature of
information lost is to be explained. This image is now to be decompressed and
the original image must be displayed
Used Functions Details:
1)
Function Name: im2double
Prototype: I2 = IM2DOUBLE(I1)
Description: It takes an image as input, and returns an image of class
double. If the input image is of class double, the output image is identical to
it.
Parameters:
o
I1: Input Image.
2)
Function Name: blkproc
Prototype: B = BLKPROC(A,[M N],FUN,P1,P2,...)
Description: It processes the image A by applying the function FUN to each distinct
M-by-N block of A, padding A with zeros if necessary. FUN is a function that accepts an
M-by-N matrix, X, and returns a matrix, vector, or scalar Y: FUN(X).
Parameters:
o
A: Input image matrix
o
[M N]: Matrix block size for processing.
26
IMAGE PROCESSING
2014
o
o
1
1
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0 ];
27
IMAGE PROCESSING
2014
Output: -
Practical No: 7
Topic: - Morphological Algorithms.
Problem Statement: A texture image or a granular image is provided as input. A suitable
algorithm that computes pattern size or granule size in terms of number of pixel
it occupies is to be implemented. This information is to display as a histogram.
Used Functions Details: -
28
IMAGE PROCESSING
2014
29
IMAGE PROCESSING
2014
title('Connected Region');
% Feature Extraction
% Measures a set of properties for each labeled region in the label matrix L.
stats = regionprops(L);
A = [stats.Area];
figure;
hist(A);
xlabel('Area in Pixels');
ylabel('Popularity');
title('Size Distribution');
% Statistical Measurement
mean(A);
std(A);
median(A);
30
IMAGE PROCESSING
2014
Output: -
31
IMAGE PROCESSING
2014
Practical No: 8
Topic: - Edge Detection.
Problem Statement: A texture image or a granular image is provided as input. A suitable edge
detection algorithm is implemented which determines the number of patterns or
granule in the input image. If there are patterns/granules of different
characteristics (like color) then their number is determined and the information
is to be displayed as a histogram.
Used Functions Details:
IMAGE PROCESSING
2014
'BoundingBox'
'ConvexArea'
'EquivDiameter'
'SubarrayIdx'
'Image'
'Solidity'
'MajorAxisLength' 'PixelList'
'Extent'
'MinorAxisLength' 'PixelIdxList'
'FilledImage'
'Orientation'
'FilledArea'
'Eccentricity'
33
IMAGE PROCESSING
2014
Output: -
34
IMAGE PROCESSING
2014
Practical No: 9
Topic: - Image Segmentation.
Problem Statement: Write a program to input an image and perform image segmentation to
extract individual objects from that image.
Used Functions Details:
35
IMAGE PROCESSING
2014
Output: -
36
IMAGE PROCESSING
2014
Practical No: 10
Topic: - Region Filling.
Problem Statement: Write a program to input an image and fill the empty region inside the
image using Region Filling procedure.
Used Functions Details:
Source Code: 37
IMAGE PROCESSING
2014
0
1
1
1
0
0
0
1
1
1
0
0
1
0
0
1
1
1
0
0
1
0
0
1
0
0
0
0
0
0
0
1
0
0
1
0
0
1
1
1
0
0
1
0
0
1
1
1
0
0
0
1
1
1
0
0;
0;
0;
0;
0;
0;
0;
0;
0;
0;
0; ];
Output: -
38
IMAGE PROCESSING
2014
Pract
ical No: 11
Topic: - Morphological Operations.
Problem Statement: Write a program to input an image and perform following morphological
operations on it:
o
o
o
IMAGE PROCESSING
2014
the input image. The rule used to process the pixels defines the operation as
dilation or erosion. This table lists the rules for both dilation and erosion.
Used Functions Details:
o
o
o
o
40
IMAGE PROCESSING
2014
Output: -
41
IMAGE PROCESSING
2014
42
IMAGE PROCESSING
2014
Practical No: 12
Topic: - Logical Operations.
Problem Statement: Performing various logical operations on an input image: AND, OR, XOR,
NOT.
Theory:
im2bw
Convert an image to a binary image, based on threshold SyntaxBW = im2bw(I,level)
BW = im2bw(X,map,level)
BW = im2bw(RGB,level)
Description
im2bw produces binary images from indexed, intensity, or RGB images. To do this, it
converts the input image to grayscale format (if it is not already an intensity image),
and then uses thresholding to convert this grayscale image to binary. The output binary
image BW has values of 0 (black) for all pixels in the input image with luminance less
than level and 1 (white) for all other pixels. (Note that you specify level in the range
[0,1], regardless of the class of the input image.) BW = im2bw(I,level) converts the
intensity image I to black and white. BW = im2bw(X,map,level) converts the indexed
image X with colormap map to black and white. BW = im2bw(RGB,level) converts the
RGB image RGB to black and white.
xor Exclusive or:
Syntax
C = xor(A,B)
Description
C = xor(A,B) performs an exclusive OR operation on the corresponding elements of
arrays A and B. The resulting element C(i,j,...) is logical true (1) if A(i,j,...) or B(i,j,...), but
not both, is nonzero.
Logical Operators:
Elementwise & | ~ Elementwise logical operations on arrays
Syntax
A&B
A|B
~A
Description
The symbols &, |, and ~ are the logical array operators AND, OR, and NOT. They work
element by element on arrays, with 0 representing logical false, and anything nonzero
representing logical true. The logical operators return a logical array with elements set
to true (1) or false (0), as appropriate. The & operator does a logical AND, the | operator
does a logical OR, and ~A complements the elements of A. The function xor(A,B)
implements the exclusive OR operation.
43
IMAGE PROCESSING
2014
44
IMAGE PROCESSING
2014
Output: -
45
IMAGE PROCESSING
2014
Practical No: 13
Aim: An input image is provided. Apply Sampling and Quantization techniques on it and
display the resulting image.
Theory:
Imresize
Resize an image SyntaxB = imresize(A,m)
B = imresize(A,m,method)
B = imresize(A,[mrows ncols],method)
B = imresize(...,method,n)
B = imresize(...,method,h)
Description
B = imresize(A,m) returns an image B that is m times the size of A, using
nearest-neighbor interpolation. A can be an indexed image, grayscale image, RGB, or
binary image. If m is between 0 and 1.0, B is smaller than A. If m is greater than 1.0, B
is larger than A. B = imresize(A,m,method) returns an image that is m times the size of
A using the interpolation method specified by method. method is a string that can have
one of these values. The default value is enclosed in braces ({}).
Source Code:clc;
close all;
clear all;
I=imread('circuit.tif');
J=imresize(I,0.5);
figure(1);
imshow(I);
figure(2);
imshow(J);
quanta=100;
img=double(I)/255;
img=uint8(img*quanta);
figure(3);
imshow(img);
46
IMAGE PROCESSING
2014
Output:-
47
IMAGE PROCESSING
2014
PRACTICAL NO:14
Aim:-A texture image or a granular image is provided as input. A suitable
algorithm that computes pattern size or granule size in terms of number of
pixel it occupies is to be implemented. This information is to be display as a
histogram.
Theory:
Regionprops
Measure properties of image regions
Syntax
STATS = regionprops(L,properties)
Description
STATS = regionprops(L,properties) measures a set of properties for each labeled region
in the label matrix L. Positive integer elements of L correspond to different regions. For
example, the set of elements of L equal to 1 corresponds to region 1; the set of
elements of L equal to 2 corresponds to region 2; and so on. The return value STATS is a
structure array of length max(L(:)). The fields of the structure array denote different
measurements for each region, as specified by properties. properties can be a
comma-separated list of strings, a cell array containing strings, the single string 'all', or
the string 'basic'.
im2bw
Convert an image to a binary image, based on threshold SyntaxBW = im2bw(I,level)
BW = im2bw(X,map,level)
BW = im2bw(RGB,level)
Description
im2bw produces binary images from indexed, intensity, or RGB images. To do this, it
converts the input image to grayscale format (if it is not already an intensity image),
and then uses thresholding to convert this grayscale image to binary. The output binary
image BW has values of 0 (black) for all pixels in the input image with luminance less
than level and 1 (white) for all other pixels. (Note that you specify level in the range
[0,1], regardless of the class of the input image.) BW = im2bw(I,level) converts the
intensity image I to black and white. BW = im2bw(X,map,level) converts the indexed
image X with colormap map to black and white. BW = im2bw(RGB,level) converts the
RGB image RGB to black and white.
Mean
Average or mean value of arrays
Syntax
M = mean(A)
M = mean(A,dim)
Description
M = mean(A) returns the mean values of the elements along different dimensions of an
array. If A is a vector, mean(A) returns the mean value of A. If A is a matrix, mean(A)
treats the columns of A as vectors, returning a row vector of mean values. If A is a
multidimensional array, mean(A) treats the values along the first non-singleton
dimension as vectors, returning an array of mean values. M = mean(A,dim) returns the
mean values for elements along the dimension of A specified by scalar dim. For
matrices, mean(A,2) is a column vector containing the mean value of each row. The
default of dim is 1.
48
IMAGE PROCESSING
2014
Std
Standard deviation
Syntax
s = std(X)
s = std(X,flag)
s = std(X,flag,dim)
Description
s = std(X), where X is a vector, returns the standard deviation using (1) above. If X is a
random sample of data from a normal distribution, is the best unbiased estimate of its
variance. If X is a matrix, std(X) returns a row vector containing the standard deviation
of the elements of each column of X. If X is a multidimensional array, std(X) is the
standard deviation of th elements along the first nonsingleton dimension of X. s =
std(X,flag) for flag = 0, is the same as std(X). For flag = 1, std(X,1) returns the standard
deviation using (2) above, producing the second moment of the sample about its mean.
s = std(X,flag,dim) computes the standard deviations along the dimension of X
specified by scalar dim.
Median
Median value of arrays
Syntax
M = median(A)
M = median(A,dim)
Description
M = median(A) returns the median values of the elements along different dimensions of
an array. If A is a vector, median(A) returns the median value of A. If A is a matrix,
median(A) treats the columns of A as vectors, returning a row vector of median values.
If A is a multidimensional array, median(A) treats the values along the first
nonsingleton dimension as vectors, returning an array of median values. M =
median(A,dim) returns the median values for elements along the dimension of A
specified by scalar dim.
Source Code:clc;
clear all;
close all;
iptImg = imread('rice.png');
subplot(2,3,1);
imshow(iptImg);
title('Original Image');
subplot(2,3,2)
imshow(iptImg);
colormap(Jet); % Sets the current figures map to JET
title('Jet Colormap Image');
% Background Estimation
49
IMAGE PROCESSING
2014
50
IMAGE PROCESSING
2014
Output:-
51
IMAGE PROCESSING
2014
PRACTICAL No:15
52
IMAGE PROCESSING
2014
Aim:- Write a Program to input an image and implement the global thresh
holding algorithms on it. Display the resulting image.
Theory:
bar, barh Bar graph (vertical and horizontal)
Syntax
bar(Y)
bar(x,Y)
bar(...,width)
bar(...,'style')
bar(...,'bar_color')
bar(axes_handle,...)
h = bar(...)
hpatches = bar('v6',...)
barh(...)
h = barh(...)
hpatches = barh('v6',...)
Description
A bar graph displays the values in a vector or matrix as horizontal or vertical bars.
bar(Y) draws one bar for each element in Y. If Y is a matrix, bar groups the bars
produced by the elements in each row. The x-axis scale ranges from 1 to length(Y)
when Y is a vector, and 1 to size(Y,1), which is the number of rows, when Y is a matrix.
bar(x,Y) draws a bar for each element in Y at locations specified in x, where x is a
monotonically increasing vector defining the x-axis intervals for the vertical bars. If Y is
a matrix, bar groups the elements of each row in Y at corresponding locations in x.
bar(...,width) sets the relative bar width and controls the separation of bars within a
group. The default width is 0.8, so if you do not specify x, the bars within a group have
a slight separation. If width is 1, the bars within a group touch one another.
bar(...,'style') specifies the style of the bars. 'style' is 'grouped' or 'stacked'. 'group' is
the default mode of display. 'grouped' displays m groups of n vertical bars, where m is
the number of rows and n is the number of columns in Y. The group contains one bar
per column in Y. 'stacked' displays one bar for each row in Y. The bar height is the sum
of the elements in the row. Each bar is multicolored, with colors corresponding to
distinct elements and showing the relative contribution each row element makes to the
total sum. bar(...,'bar_color') displays all bars using the color specified by the
single-letter abbreviation 'r', 'g', 'b', 'c', 'm', 'y', 'k', or 'w'. bar(axes_handles,...) and
barh(axes_handles,...) plots into the axes with handle axes_handle instead of the
current axes (gca). h = bar(...) returns a vector of handles to barseries graphics objects.
bar creates one barseries graphics object per column in Y. barh(...) and h = barh(...)
create horizontal bars. Y determines the bar length. The vector x is a monotonic vector
defining
the
y-axis
intervals
for
horizontalbars.
53
IMAGE PROCESSING
2014
Source Code:clc;
close all;
clear all;
a=imread('circuit.tif');
[row col]=size(a);
h=zeros(1,256);
for n=1:1:row
for m=1:1:col
t=a(n,m);
h(t)=h(t)+1;
end
end
figure(1),imshow(a);
figure(2),bar(h)
[X,Y]=ginput(1);
for x=1:1:col
for y=1:1:col
if a(x,y)<X
a(x,y)=0;
else
a(x,y)=255;
end
end
end
figure(3),imshow(uint8(a));
Output:
54
IMAGE PROCESSING
2014
55
IMAGE PROCESSING
2014
56