Counting rice - KsuWeb

peachpuceAI and Robotics

Nov 6, 2013 (3 years and 7 months ago)

99 views

PAINSTAKINGLY

COUNTING RICE

Morphology and Object Recognition in Image Processing

Franz Parkins and Lamar Davies


Mentored by: Dr. Josip Derado


Ph.D

Morphology


The term morphology refers to the form or
structure of anything; hence linguistic
morphology , Geomorphology, Bio
-
morphology,
Cosmic morphology, etc.


Morphology in Industry and
Research


Morphology is prolific in industry.


A wide variety of unpolished ideas lie at
the forefront.

The Ultimate Goal


Our focus is on:

1.
Detecting objects

2.
Enumerating them

Characterization


Morphological characterization for object
recognition is, put simply, to decipher
between the objects and their background.

Complexity of Algorithm


The Algorithm has two main parts;
CLEANING and COUNTING.

Cleaning Rice



This step doesn’t involve a tiny broom.
Metaphorically however, it is oddly
appropriate, as we must somehow ‘sweep
away’ all of the non
-
relevant data that will
prevent an accurate rice count.

But Wait!!!!!


It is an absolute necessity to have quality
photos! This it true for two reasons:


1.
Clarity prevents “clutter”


2.
Standardized distance

Humble Beginnings

(The Lego Contraption)

Second Attempt

(Crude but Effective)

Base Image

Basic Contrast Cleaning Method

Grid Filter Cleaning

Strel Filter Method

(Mathworks Image Filter)

Circular Filter Cleaning

Combined Filter

Original image

Strel + Contrast + Grid

Filters

Combined Filter

Original image

Contrast + Circle + Grid

Filters

How Do We Actually Count Rice?


Area Estimation


Border Following


Horizontal Layered Scanning (HLS)

Area Estimation



The idea behind area estimation is
simply to count the number of rice pixels in
the image and then divide by the number
of pixels in an average single rice grain.

2,694 pixels!!

Area Estimation


Pros:


Easily implemented


Less complex


Cons:


Reliance on average grain size (variance)


Inability to use destructive filters


Border Following


The intention is to define the border and
starting pixel of each rice grain, then follow
each border around to the starting point,
thus circling the rice grain and marking it
as counted before moving on to the next.

Border
-
defined Image

1

3

2

6

5

4

9

8

10

7

Border Following


Pros


Very accurate and easy to filter “false”
rice


Cons


Algorithm exceeds limits of Matlab
unless used in conjunction with a very
small image (approx 200x200 pixels).


Difficult to differentiate rice in close
proximity.

Horizontal Layered Scanning



HLS scans the image one row at a time
while comparing to the previous row. The
amount of rice scanned in each row is
tracked, tallied, and counted accordingly.

Horizontal Layered Scanning

[1, 0]

[2, 0]

[1,1]

[0, 2]

[1, 2]

[0, 3]

Horizontal Layered Scanning



Pros


Easily implemented and accurate


Does not rely on massively looping
algorithms, making it more efficient


Cons


Accuracy is greatly dependent on quality
cleaning


Consecutive line errors

Solving Consecutive Line Errors

Rice Count Chart

(Using Industry Grade Strel Filter w/ HLS)

Actual #

Number of Rice Counted

Accuracy

10

9.4

9.6

9.4

9.8

10.0

96.4%

20

21.0

19.2

19.4

19.8

19.3

96.7%

30

28.0

29.0

30.0

29.4

29.0

96.9%

40

37.3

40.3

39.3

40.2

40.0

98.1%

50

48.6

46.0

48.2

51.2

46.2

96.1%

60

57.8

52.6

54.6

58.8

57.6

93.8%

70

62.8

67.4

65.4

66.2

69.4

94.6%

80

71.8

79.5

76.0

74.2

74.6

94.0%

90

82.4

81.0

84.2

83.8

86.8

92.9%

100

94.8

93.4

95.2

97.2

91.0

94.3%

OVERALL

ACCURACY

With industry grade strel filter

95% !!!

Rice Count Chart

(Using our Circular Filter w/ HLS)

Actual #

Number of Rice Counted

Accuracy

10

9.50

10.00

9.25

9.25

9.75

95.50%

20

19.50

19.75

19.00

19.25

19.75

97.25%

30

28.75

29.25

29.75

29.25

28.25

96.83%

40

39.25

40.75

38.25

37.25

38.75

96.38%

50

47.50

48.50

48.00

46.25

42.75

93.20%

60

55.00

53.00

51.50

53.50

55.25

89.42%

70

62.25

62.25

63.5

66.25

66.00

91.50%

80

74.00

73.75

72.25

75.75

73.50

92.31%

90

81.00

72.00

87.50

85.67

71.00

88.26%

100

87.25

90.75

83.33

87.67

90.00

87.80%

OVERALL

ACCURACY

With our original circular filter

93% !!!

Progression


Given more time, we would use this
program to bring about world peace, and
of course count the amount of rice it takes
to cure world hunger…. By hand… and
then have our program tell us that we are
a couple of grains short of a bushel!!

No, Seriously

given more time…


Refine the border program with switches.


Tracking rice centers instead of averaging
counts on multiple scans.


Better recognition of multiple
-
rice image
segments.


Reconstruction of overlapping rice.

THANK YOU

FOR YOUR TIME!


ANY QUESTIONS?