Assignment 2

CS 585 HW 2
Jeanpiere Solorzano
September 26 2018

Problem Definition

Design and implement algorithms that can analyze and recognize random shapes. The shapes are categorized into three types: square, circle and equilateral triangle. For each image, we have to detect the image, create borders, and evaluate their shape.

Method and Implementation

Shape blobs: Determine the background color and traverse through the image. When a different color hits, make blobs's shape stand out by making the background color black
Border Algorithm Go through each pixel of the image and detect when two different pixels are next to each other. Look at the neighbors of the current pixel. If they are all similar we know that this is not a border pixel


Run the code multiple times and used the functions offered by OpenCV in order to check that the output that came from the algorithm I created were similar to functions already made for that purpose. Unfortunately there were many similar pixel colors that made this process tedious because random colors inside the blobs were being changed to background colors.


IMG 1001 | 1200 | 1496

blob     |     border      |     source

blob border src
blob border src
blob border src
blob border src


Attempted to use Binary Images and Histograms in order to detect the blobs and create borders for them. However, this turned out to be complicated as many pixels inside the image were made part of the background. I utilized medianBlurr in order to help with this problem but it wasn't enough. Ultimately I decided to use a simple algorithm that would traverse each pixel and check for neighbor values in order to undertand the shape of the blob and acquire its borders. In some scenarios this algorithm worked better than others as can be seeing by the pictures.


It can be quite difficult to acquire a blob and check its boderders if other objects in the image have a similar color value. For the future I will definitely have to come up with a better system to determine the shape of objects.

Credits and Bibliography

Used the following documentation site to write the program: