[mmdPieces] [Up] [mmdRobotop] Demonstrations

mmdPotatoes
Grade potato quality by shape and skin spots.

Description

The input image is a gray-scale image of several washed potatoes. The shape of the potatoes is analysed using skeleton feature and the skin spots are detected. These two features can be used to evaluate their visual quality.

Illustrated Source Code

Reading

The input image is read.

Image a = mmReadgray("potatoes.tif");
mmShow(a);

a

Thresholding

Convert to binary objects by thresholding

Image b = mmThreshad(a,90);
mmShow(b);

b

Skeleton of the potato shapes

The binary image is thinned and the result overlayed on the original image

Image c = mmThin(b);
mmShow(a,c);

a,c

Closing tophat

To detect the skin spots, a closing tophat can enhance the dark areas of the image

Image d = mmCloseth(a,mmSedisk(5));
mmShow(d);

d

Thresholding and masking

The tophat is thresholded and the result is masked with the binary image of the potatoes as we are interested only on the spots inside them

Image e = mmThreshad(d,20);
Image f = mmIntersec(e,b);
mmShow(f);

f

Final display

Show both results: skeleton and skin spots overlayed on the original image

mmShow(a);
mmShow(a,f,c);

a a,f,c

[mmdPieces] [Up] [mmdRobotop]