Submitted by: Submitted by sirlegendary
Views: 74
Words: 802
Pages: 4
Category: Science and Technology
Date Submitted: 11/07/2014 11:20 AM
* Computer Vision Coursework
CI3430
Counting Coins - 2012
Introduction
For this coursework, I chose to write a program, which is called “Counting Coins”. The aim of this program is to detect objects such as British coins on any image. It then displays the recognized coin in the center with its measurements such as the area and parameter. The program then adds all the coins together and displays the total in Pennies.
I used Matlab to create this program, as it has many of the necessary functions already implemented. All the functions used in this summary are all from the official Matlab website:
http://www.mathworks.co.uk/help/matlab/index.html
Reading Image
Reading Image
In the first line of my code I stored an image into an array called “image01” by using the function “imread”. This allows me to be flexible with using different image files without having to modify all my codes.
Converting into gray scale
Converting into gray scale
I then gray scaled the original image and saved it into an array called “G” by using the “rgbtogray” function. The image is now in gray scale and ready to be threshold.
Threshold
Threshold
At first I used the “im2bw()” function to threshold my image but it doesn’t threshold certain images accurately. Here is an example of the result of using the “imb2bw” function:
bw = im2bw(G);
bw = im2bw(G);
The only way I was able to solve this problem was to display the histogram of my image, which will then help me choosing the right threshold value. Matlab has a function called “imhist()” which allowed me to display the histogram of the image I want to threshold.
In this example the threshold value would be 15.
In this example the threshold value would be 15.
This is the result I got after using Histogram to determine the right threshold value.
This is the result I got after using Histogram to determine the right threshold value.
bw = G > 15;
bw = G > 15;...