Detect broken rounded biscuits.
The input image is a gray-scale image of two rounded-shaped biscuits. One of them is broken. The purpose is to detect the broken biscuit.
The input image is read.
1. a = adreadgray('cookies.tif') 2. adshow(a)
Convert to binary objects by thresholding
1. b = a >= 100 2. adshow(b)
Open tophat with large octagon disk
The tophat of the binary image by an octagon disk with a radius fits the good biscuit but does not fit in the broken biscuit can detect the broken one.
1. import ia870 as mm 2. c = mm.iaopenth(b,mm.iasedisk(55,'2D','OCTAGON')) 3. adshow(c)
Remove the residues
Clean the residues from the octagon disk and the rounded shaped biscuits by eliminating small connected regions
1. d = mm.iaareaopen(c,400) 2. adshow(d)
Display the detected broken biscuit