Experiment 4: Broken biscuits Adrian F. Clark
This experiment asks you to identify biscuits as being circular, rect- angular or broken using the techniques discussed in Chapter 5 of the lecture notes and mirroring the example system described in Sec- tion 5.5.
Contents
1 Introduction 2
2 Improving the thresholding 2
3 What kind of biscuit is it? 3
1 Introduction
Bearing in mind how many times the lectures touch on broken bis- cuits, it was bound to happen: an experiment that involves you re- cognizing whether images containing biscuits are complete either circular or tectangular or broken. Your starting point is a program called bikky which does the following to each image given on its command line:
1. the image is read in as grey-scale;
2. it is thresholded using a fixed value;
3. the resulting binary image is tidied up using morphological op- erations;
4. contours are found around each foreground object; 5. each contour is processed;
6. some text is written on the image.
You run it with a command such as:
./bikky biscuit-*.jpg
and it yields output such as that shown in Figure 1. However, the
program is incomplete in that it does not classify the contours found into the three categories that is your job. The program and a set of images are to be found in the zip-file for this experiment.
2 Improving the thresholding
You will see from bikkys output that it does not threshold the bis- cuit from the background particularly well and often finds spurious foreground regions. If you look at the code, you will see it uses a fixed threshold. You might be able to improve contour detection by changing the value of the threshold it uses, or you may find that an adaptive threshold works better. This functionality is available in
Figure 1: Example output from bikky
experiment 4: broken biscuits 2
OpenCV, so explore that and see if you can improve the programs thresholding stage to find the biscuits more reliably. If you do that, you might also be able to reduce the amount of morphological pro- cessing.
3 What kind of biscuit is it?
OpenCV has the ability to find contours in thresholded images, equi- valent to the region labelling approach described in Chapter 5 of the notes. It is able to compute a variety of features of any contour; see for example
https://docs.opencv.org/master/dd/d49/tutorial_py_contour_features.html
for a description of them. By combining these features, you should be able to determine whether a particular contour is a circular or rectangular complete biscuit or that the biscuit is broken in some way. Your second task is to determine the category and write that onto the image. (There is code in bikky that draws the contours and writes text.)
Do show your solution to a demonstrator.
experiment 4: broken biscuits 3
Reviews
There are no reviews yet.