Assessment|159.102 Instructions for Assignment 3

Section A – input
The input to your program is the photo taken by the camera in the factory. This is available in a .ppm file called Buttons.ppm. This file is available under Assessments on Stream. Do not edit this file in any way.
If you accidently modify the file then download a fresh copy of the file from Stream.
Your program must be able to work with any such photo. Do not assume a specific number of buttons.
do not assume that buttons will always be in the same place in the photo.
(Hint: Before starting on your program, check that the .ppm file has no errors. Download Buttons.ppm from Stream and convert it to .bmp (or other format) and look at it. The display should look like this:
Just for interest – you can tell that the resolution of the camera is low because of the “stepped” edges to the buttons in the image. Actually, for many problems of this type (i.e. identifying defects in products) it is often better to use a black-and-white photo because the defects stand out more clearly.
Section B – understanding the problem
Like many “real-life” systems, this type of project can never be perfect (which is what makes real-life projects interesting). We do the best we can by noting the following:
Notes about the problem:
1.Buttons appear as white (or li

💡 Buy the answer for only $12 Get it now →

ght grey) objects on a dark background. This is a black-and-white photo which means every pixel is a shade of grey (i.e. the R, G and B values are the same for each pixel). We define a pixel to be part of a button if its R (or G or B) value is greater than 128.
2.There will always be a few pixels around the edge of a button (depending on the shadows) that are darker than this and will thus not count as part of the button. This does not matter.
3.We need to know how to “identify” a button. Basically we look for pixels where the R value is greater than 128. But we need more than this – see next section below.
4.To draw a box around a button you need to know the minimum and maximum x-value of all pixels in the button and also the minimum and maximum y-value of all pixels. The box then has a top left corner of (xmin, ymin) and a bottom right corner of (xmax, ymax) and so on.
5.Some thought needs to be given to how we define a “damaged” button. This is entirely up to you.
Hint: a damaged button will have less total pixels than an undamaged button.
Section C – the algorithm to identify a button in the image
A button consists of pixels with R value greater than 128 AND the pixels must touch each other. If we work through every pixel, we can identify a button by:

💡 Buy the answer for only $12 Get it now →