Representation and Description Examples 1 Colorado School of Mines

advertisement
Representation and Description
Examples
Colorado School of Mines
Image and Multidimensional Signal Processing
1
Example 1 – Chain Code (Sect 11.1.2)
• Find the chain code for this figure.
• Find the first difference of the chain code.
• To normalize this sequence and make it independent of the
starting point, find the chain code that has the minimum
numerical value (this is the “shape number”).
Colorado School of Mines
Image and Multidimensional Signal Processing
2
Example 2 – Fourier Descriptors
• Compare the FDs for these shapes – see slides 15-17
Colorado School of Mines
Image and Multidimensional Signal Processing
3
Example 3 – co-occurrence matrix
• The two checkerboard images below are each 8x8
binary images, where black=0 and white=1.
Image 1
Image 2
• Estimate (by hand) the co-occurrence matrices for
each of the images, using the position operator “one
pixel to the right”.
Colorado School of Mines
Image and Multidimensional Signal Processing
4
Colorado School of Mines
Image and Multidimensional Signal Processing
5
Example 3 – co-occurrence matrix (continued)
• Compute the “contrast” feature for each image:
K
K
∑∑ ( i − j )
=i 1 =j 1
2
pij
• where pij is the probability that a pair of points
satisfying the position relationship will have the
values (zi,zj).
Colorado School of Mines
Image and Multidimensional Signal Processing
6
Colorado School of Mines
Image and Multidimensional Signal Processing
7
Example 4 – co-occurrence matrix
• Four 100x100 binary images are shown below. In each, the
area of the white (gray value 1) regions is equal to the area of
the black (gray level 0) regions.
Random noise
image
Four horizontal stripes,
each 25 pixels wide
Four vertical stripes,
each 25 pixels wide
Large black and
white blobs
• Estimate the gray level co-occurrence matrix for each image,
using the position operator “one pixel to the right”.
Colorado School of Mines
Image and Multidimensional Signal Processing
8
Colorado School of Mines
Image and Multidimensional Signal Processing
9
Example 5 – Matlab functions
clear all
close all
glcm =
graycomatrix(I);
• Creates a gray level
co-occurrence matrix
from image I.
• Default offset is 1
pixel to the right (can
change this).
• Default number of
gray levels is 8 (can
change this).
Also see
graycoprops,
entropyfilt, stdfilt
Colorado School of Mines
filenames = {
'Fig1128(a).tif';
'Fig1128(b).tif';
'Fig1128(c).tif'};
% Corresponding rectangles to extract regions of interest.
rects = {
[60, 220, 80, 80];
[40, 145, 80, 80];
[5, 20, 80, 80]};
for iFile=1:length(filenames)
fname = filenames{iFile};
I = imread(fname);
figure, imshow(I, []);
rect = rects{iFile};
rectangle('Position', rect, 'EdgeColor', 'r');
I = imcrop(I,rect);
glcm = graycomatrix(I, 'NumLevels', 256);
figure, imshow(glcm,[]);
pause;
end
Image and Multidimensional Signal Processing
10
Statistical Descriptions of Texture
Add Matlab code to compute
• Mean
L −1
m = ∑ zi p ( zi )
I = imread(filename);
figure, imshow(I, []);
i =0
• Variance
L −1
σ = ∑ ( zi − m) 2 p ( zi )
rectangle('Position', rect, ...
'EdgeColor', 'r');
2
• R value
i =0
R = 1−
1
1 + σ 2 /( L − 1) 2
• Uniformity
L −1
• Entropy
U = ∑ p 2 ( zi )
I = imcrop(I,rect);
[H,z] = imhist(I);
p = H/sum(H);
figure, plot(z,p);
m = sum(z.*p);
fprintf('Mean = %f\n', m);
v = sum(p.*((z-m).^2));
s = sqrt(v);
fprintf('Std deviation = %f\n', s);
:
i =0
L −1
e = −∑ p ( zi ) log 2 p ( zi )
i =0
Colorado School of Mines
Note: To avoid computational errors where
p=0, restrict the summation to those values of
p>0. An easy way in Matlab is to first do
p = p(p>0);
Image and Multidimensional Signal Processing
11
Example 5 – Figure 11.28
See if you
get these
values
Matlab
“rectangles”:
[x0,y0,width,
height]
“Smooth”
rect = [60, 220, 80, 80];
Mean
Std deviation
R value
Uniformity
Colorado Entropy
School of Mines
“Coarse”
rect = [40, 145, 80, 80];
78.415028
120.642280
11.893195
74.141785
0.002171
0.077947
0.032593
0.004648
5.305217Image and Multidimensional
7.854313
Signal Processing
“Regular”
rect = [5, 20, 80, 80];
99.116141
33.680034
0.017146
0.013492
6.603116
12
Example 5 – new images
• Next, compute the measures for these images :
“Fig0114(a).tif”, “Fig0114(d).tif”, “Fig0114(e).tif”
• For each of these, crop a rectangular subimage using the
rectangle [300, 300, 100, 100].
Mean
Std deviation
R value
Uniformity
Entropy
Colorado School of Mines
Image and Multidimensional Signal Processing
13
Download