Simple Starting Implementation

In order to compare segments with each other, I have decided to calculate the angles of the segments. This would allow us to get similar shaped segments when replacing parts of the original image. In order to get angles information we are only taking the vertex positions for each segment when creating them using the hough-line transform.

With this information we could then use the dot product to find an angle at a particular vertex. We could then do this method to compare all angles with other segments. If we find that we have too many matches for particular segements with similar angles, we will then start to check edge length. The segments with the most similar edge lengths and angles will be favoured. If there are still too many segments, one will be chosen at random and will be placed in the position of the original segment position.

float Shape::getAngle(int i){
    int prev,next;
    if(i==0) prev= vertices.size()-1;
    else prev=i-1;
    if(i==vertices.size()) next= 0;
    else next=i+1;

    ofVec2f vectorOne = vertices[i]-vertices[prev];
    ofVec2f vectorTwo = vertices[i]-vertices[next];

    float theta = acos((vectorOne.x*vectorTwo.x+vectorOne.y*vectorTwo.y)/(vectorOne.length()*vectorTwo.length()));
    return theta*180/PI;
}
Get Angle Function used for segments