-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy_analysis.m
More file actions
53 lines (45 loc) · 916 Bytes
/
my_analysis.m
File metadata and controls
53 lines (45 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
%original image
x = imread('rice.png');
imshow(x)
title('Raw Image')
%color map
figure
imshow(x)
colormap jet
title('Jet color map')
%background estimation (non uniform illumination)
bg = imopen(x,strel('disk',10));
figure
imshow(bg)
colormap jet
title Background
%background removal (flatten background level)
y = imsubtract(x,bg);
figure
imshow(y)
title Flattened
%segment grains from background
bw = im2bw(y,graythresh(y));
figure
imshow(bw)
title GrayThreshed
%label connected regions
L = bwlabel(bw);
figure
imshow(L,[])
colormap jet
pixels
title('Connected Regions')
feature extraction - size distribution (area, pixels)
stats = regionprops(L);
A = [stats.Area];
figure
hist(A)
xlabel('Area (pixels)')
ylabel Popularity
title('Size Distribution')
%statistical measurements
mean(A)
std(A)
median(A)
% Copyright 2004-2010 RBemis The MathWorks, Inc.