Demo iadpotatoes

namespace:morph
page:iadpotatoes

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.

Script

Reading

The input image is read.

1. a = mmreadgray('potatoes.tif');
2. mmshow(a);

Thresholding

Convert to binary objects by thresholding

1. from ia870 import iathreshad
2. 
3. 
4. b = iathreshad(a,90);
5. mmshow(b);

Skeleton of the potato shapes

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

1. from ia870 import iathin
2. 
3. 
4. c = iathin(b);
5. mmshow(a,c);

Closing tophat

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

1. from ia870 import iacloseth
2. from ia870 import iasedisk
3. 
4. 
5. d = iacloseth(a,iasedisk(5));
6. mmshow(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

1. from ia870 import iaintersec
2. 
3. 
4. e = iathreshad(d,20);
5. f = iaintersec(e,b);
6. mmshow(f);

Final display

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

1. mmshow(a);
2. mmshow(a,f,c);