Sunday, November 14, 2010

Algorithm

The algorithm needs to include the following:


Load image from camera or file
Gray scale image
Find pixel matrix of image - print out
Find Edges- change color of edges to blue
Print edge point coordinates
Check for Shape
- Circle: find center point by using edge points, find radii -->


  public int radiusAverage(double listOfRadii[]){
        int sum=0;
        for (int x=0;x< listOfRadii.length;x++){
            sum += listOfRadii[x];
        }
        sum = sum/listOfRadii.length;
        return sum;
    }


              GIVEN: list of radii
              if  radiusaverave =radiusAverage(listOfRadii);
               for (int x=0;x
//            System.out.println("radii difference: " + listOfRadii[x]/radiusaverave);
            if (listOfRadii[x]/radiusaverave > 4.4){ //CHANGE 4.4 MAYBE

                   NOT A CIRCLE
- Square:
0,1,2,3,4,5,6,7,8,9,10
1
2
3
4
5
6
7
8
9
10

0,00; 1,00; 2,00; 2,00; 3,00; 4,00; 5,00; 6,00; 7,00; 8,00; 9,00; 10,00; 
0,01                                  10,01
0,02                                  10,02
0,03                                  10,03
0,04                                  10,04
0,05                                  10,05
0,06                                  10,06
0,07                                  10,07
0,08                                  10,08
0,09                                  10,09
0,10; 1,10; 2,10; 2,10; 3,10; 4,10; 5,10; 6,10; 7,10; 8,10; 9,10; 10,10; 


square - go through list until y changes... the list up until when Y changes is the upper line of the square.. record # of numbers in a variable topside. *this will be checked with another one later*

Go through loop.. (for... ){ list[x] == (look for X coord.) After Y changes, look for change in X. Add each one to a varialbe
rightside or leftside.


In the latter loop ^ have another loop that checks for a change in Y.. *really it checks that it doens't change*

With the following numbers add them up and save in bottomside
check if (topside and bottomside) and (rightside and leftside) have the same # of numbers
If yes, it is a square

- Triangle:

Triangle:

---    ---    ---    3,0    4,0    5,0     ---    ---    ---   ---    12/3 = 4
---    ---    2,1    3,1    4,1    5,1    6,1    ---    ---   ---    20/5 = 4
---    ---    2,2    3,2    ---    5,2    6,2    ---    ---   ---     16/4 = 4
---    1,3    2,3    ---    ---    5,3    6,3    ---    ---   ---     14/4 = 3.5
---    1,4    2,4    ---    ---    ---    6,4    7,4    ---   ---     16/4 = 4
0,05   1,5    2,5    ---    ---    ---    6,5    7,5    ---   ---     16/4 = 4
0,06   1,6    ---    ---    ---    ---    ---    7,6    8,6   9,6    25/4
0,07   1,7    ---    ---    ---    ---    ---    ---    8,7   9,7    18/3 = 6
0,08   ---    ---    ---    ---    ---    ---    ---    8,8   9,8    17/2 = 8.5
0,19   ---    ---    ---    ---    ---    ---    ---    ---   9,9    = 9


add up X values until Y value changes, The average of each line should be relatively the same/ increase as it gets to the end. If so, the image is a triangle

No comments:

Post a Comment