# Calculate the area and perimeter of a hand-drawn shape

I need to know whether my idea for my final year project could be achieved or not. If its achievable please guide me with the relevant language and other frameworks.

The idea

I have a piece of paper (A4) on which I draw a circle. Once it is drawn I need to calculate the area and perimeter. In order to calculate the area and perimeter I move the mouse pointer on the image borders. Then the area and perimeter is calculated. Input of the image could be fed into the application via scanning or capturing as an image.

• Welcome to SciComp! When you say draw a circle I am guessing you don't mean a perfect circle but rather some closed curve (possibly peanut shaped for example)? I think this could be done, for example if it is fed into your application as a pixel image of black and white then you can just store your image as an array of 1's and 0's (say 1 for black and 0 for white). From there I think it wouldn't be too hard to find the approximate area via a Riemann-like sum of rectangles. Nov 19 '15 at 6:43
• Please don't cross-post: stackoverflow.com/q/33794887/491171 Nov 19 '15 at 7:17
• It is not clear how the piece of paper is going to become an image: if you scan it things get better (still you have to cope with greyscale thresholds and so on); if you want to take a photo of the A4 sheet then you will neep perspective corretion, barrel correction, lighting balancing, ...
– N74
Nov 19 '15 at 11:59

Writing my comment idea in more detail: Lets say you have your image input to your application as a black and white pixel array, for example something like:

Then each black pixel can be represented with a 1 and each empty white pixel represented with a 0. The corresponding array would look like:

\begin{array}{c c} 0 & 0 & 1 & 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0 & 1 & 1 & 0\\ 1 & 0 & 0 & 0 & 0 & 0 & 1\\ 1 & 0 & 0 & 0 & 0 & 0 & 1\\ 0 & 1 & 0 & 0 & 1 & 1 & 0\\ 0 & 0 & 1 & 1 & 0 & 0 & 0\\ \end{array}

Once you have this you can just loop through the two dimensional array and find the approximate area by counting the number of white pixels inside the drawn object. Obviously in with an image with much finer detail the array becomes larger but I think the same idea will work. Even an image that is $1000\times{}1000$ pixels will still only contain 1 million entries and only a fraction of them would be ones. The perimeter is even easer as you simple have to count the number of black pixels.

In terms of whether this is a "good" project I can only say that I am glad that I don't have to do it. I think the vast majority of the work you will have to put in to it is going to be in user interface design. How we go from a piece of paper to a filtered image where my algorithm suggestion will work is going to be the hard part. Then again maybe this is for a UI class? Any ways good luck.