GithubHelp home page GithubHelp logo

circles's Introduction

circles

This program detects circles in an image and mark their edges.

It is done for a scientific programming course at KTH, and is implemented in MATLAB.

Description

The aim of this project is to detect circles in an image and mark the edges in MATLAB. The circles in the images are coins of different sizes. The image is loaded into the workspace using the “imread” function, which resulted in a 3D matrix.

For further processing of the image it is preferable to convert the image to a 2D matrix, i.e. a grayscale image. This is done by multiplying each dimension with a constant, eliminating the third dimension.

The next step of this project is to use the Sobel Operator on the grayscale image. The Sobel Operator creates a new binary image using the grayscale image where all the changes in contrast are marked with ones, and where there is no change in contrast in the picture, there will be zeros. This results in a picture with all the coin edges marked with white and everything else is a black background, as can be seen in the plot titled “Sobel”.

To achieve this, two masks, called F1 and F2, are convolved with the x- and y-direction of the image. Then the square root the two products results in a matrix requiring further processing. This matrix has larger values where the contrast changes. A new, binary matrix is constructed that has ones where the value is greater than a threshold (found by trial and error). All the values lesser than the threshold are set to zero.

Upon receiving the binary picture after the Sobel Operation is done, Hough Transform is performed. Hough Transform is used to find shapes in images by voting.

Firstly, a 3D Accumulator Matrix is created, which has three parameters, the circles x and y coordinates and the circles radii. Then the voting procedure is constructed using for-loops. For each pixel of the image, if the equation of a circle with a known radii is fulfilled in relation to a threshold, the coordinates for the circle in the accumulator are voted for, meaning increasing a specific index value in the accumulator by +1. Therefore the centers of the circles in the image are expected to have many more votes than other indexes.

Secondly, a filter is constructed, which ignores all small values in the accumulator because they cannot correspond to a circle and are seen as a noise.

Thirdly, by using the function “imregionalmax”, maximas in the accumulator are found and assign as coordinates.

Finally, the coordinates are used to draw green circles over the original image.

After all this is done, plotting the graphs is desirable to see the results, along with checking the time it takes to run the project.

How to run

Open the file "detector.m" and change the input to whatever picture you would like to test.

Some images are included here. The code works best for images: test_uniform16.jpg, test_uniform17.jpg, test_uniform4.jpg.

circles's People

Contributors

til117 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.