1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

What would that cost?

Discussion in 'General Programming Chat' started by bildderfrau, Mar 11, 2011.

  1. bildderfrau

    bildderfrau Newbie

    Oct 23, 2010
    Likes Received:

    i need for a school project an ellipse detection for my further c++/cimg code. here are the steps, which are neccessary:
    [*]The following algorithm compares every white pixel to every other white pixel.  We?ll call the first Xi and the white pixel compared to Xj.
    [*]- Calculate the distance between Xi and Xj divided by two and store it in ?a?. If ?a? is less than a pre-determined ellipse ?a? minimum (30) than move on to the next pixel, same goes for a greater than threshold (45).
    [*]- Calculate the angle of the two pixels and store it in alpha.
    [*]- Calculate the midpoint and store it in ?m?.
    [*]- Now we once again look at every other white pixel (hence the O(n^3)). We?ll call this one Xk. For each Xk calculate the distance between it and ?m? and store that in ?d?.  Compare it to the ?b? threshold of 15 min/40 max, if it fails move onto the next one.
    [*]- Next we calculate the angle between Xk and ?m? and store it in theta.
    [*]- Now for the heart of the algorithm, calculate the ?b? value of the ellipse for these points using a bit of algebra against ellipse equations you can arrive at b=(a^2*d^2*sin^2(theta))/(a^2-d^2*cos^2(theta))^.5
    [*]- Increment the ?b? count for the found ?b?.  ie if ?b? is ?2? then record that ?2? has shown up once, if ?2? appears from another Xk then it has appeared twice etc.
    [*]- Once all of the Xk?s have been exhausted find the ?b? value that has appeared the most often and compare this value against every other Xi/Xj pair?s highest ?b? count and whichever has the largest amount of values that create the most amount of similar ?b? values is the best fit ellipse for the image.
    [*]- Now that you have the best fit ellipse values you can easily calculate everything needed to draw the ellipse.
    my question is now, what it would cost if someone would code this for me.

    thanks so far