Task 1

Step 1

Figure 1.1 Original `pillsetc.png`.

Step 2

Figure 1.2 Thresholded image.

Step 3

Figure 1.3 Removed noise and small objects.
Figure 1.4 Cap gap is filled.
Figure 1.5 Filled holes.

Step 4

Figure 1.6 Label image.

Step 5

Figure 1.7 Image where round objects are indicated with a red disk at the centroid.

Object properties

Object Area Perimeter Roundness
0 882 110.57 0.907
1 876 110.57 0.900
2 16,928 543.05 0.721
3 3,026 261.12 0.558
4 8,074 338.88 0.884
5 4,908 264.01 0.885

Task 2

Step 1

Figure 2.1 Original image `rice.png`.

Step 2

Figure 2.2 Background image.

Step 3

Figure 2.3 Forergound image.

Step 4

While the histogram equalization indeed increased the contrast, it enhanced the contrast in the background to much for it to be useful. Admittedly, a better contrast enhancer should have been used.

Figure 2.4 Foreground (left) and histogram equalized image (right).

Step 5

Because of the contrast adjustment failure discussed in Step 4, we threshold the foreground image directly.

Figure 2.5 Thresholded foreground, where threshold = 49 is computed with Otsu binarization.

Step 7

Figure 2.6 Image of grain with label 43.

Step 8

Figure 2.7 Graylevel (with colormap `magma`) label image (left), and RGB label image (right).

Step 11

Figure 2.8 Area distribution.

Step 12

Figure 2.9 Angle distribution.

Step 13

Here we plot the annoted image. Note that some objects like number 18 and 49 are the result of not being able to separate some of the grains.

Figure 2.10 Image where the major axis (with arbitrary length) is marked on each object. The centre dot of the axis represents the centroid. Green labeled objects have an angle in [-20, 20] degrees, and blue objects have an angle outside that range.

Task 3

We where suppose to estimate the area and perimeter of the difference circles shown in Figure 3.1, Figure 3.2, and Figure 3.3.

Figure 3.1 'circle2.png' with grid to enhance pixels.
Figure 3.2 'circle5.png' with grid to enhance pixels.
Figure 3.3 'circle15.png' with grid to enhance pixels.

The results that are as follows, note that the perimeter and area computed from the radius is a difficult standard to live up to as these objects are not continuous. Also, note that the boult in routines from OpenCV seems to be using Freeman chain code to estimate the perimeter and area from the contour points.

Perimeter circle2 circle5 circle15
From radius 12.57 31.42 94.25
CC Freeman 13.66 35.31 101.25
CC Kulpa 12.95 33.48 96.00
CC Vossepoel 12.83 33.04 95.23
Contour naive 15.00 39.00 119.00
Contour OpenCV 13.66 35.31 101.25
BQPM 4-connected 20.00 44.00 124.00
BQPM Duda 16.49 38.14 104.08
BQPM Gray 20.00 44.00 124.00
Area circle2 circle5 circle15
From radius 12.57 78.54 706.86
CC Freeman 14.00 84.00 716.00
Contour OpenCV 14.00 84.00 716.00
BQPM 4-connected 21.00 101.00 761.00
BQPM Duda 21.50 102.00 765.00
BQPM Gray 21.00 101.00 761.00

Task 4

a)

The moments of inertia of an image (around a point is simply the second order moment around said point (referring to the notes for reference).

b)

For a 2D object to exhibit a unique orientation, the requirement is simply , where denotes the central moments.

c)

For the first one

And for the second