How to filter the points to get only the left most and right most?

This is a discussion on How to filter the points to get only the left most and right most? within the C Programming forums, part of the General Programming Boards category; Hi all, Kindly need your attention here. Let say, Code: n = 0; // number of corner points detected if ...

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    17

    How to filter the points to get only the left most and right most?

    Hi all,
    Kindly need your attention here.
    Let say,
    Code:
    n = 0;  // number of corner points detected
    if (......)
    {
    corner_list[n].x = j;  //x coordinate
    corner_list[n].y = i;  //y coordinate
    n++;
    :
    :
    }
    "m7.pgm"-->attached (converted to .bmp)
    This is the image and the marking at the contour are the detected points.
    "m-004-1.pgm"-->attached (converted to .bmp)
    I want to get only the left most and right most points as corner. How can i write the codes to keep only these 2 corner points for every image?
    From the left side, we can see there are two points with the same x-coordinate. From the right there are 3 or 4 points at the same x-coordinate.
    How can we program to choose the most middle position for the left most and right most corner points?

    Please help or give some ideas.
    Thank you.

    Best regards,
    Tommy
    Attached Images Attached Images   

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,794
    Find the uppermost and lowermost points and get the average y-value of those points, this is the "most middle position" you are talking about. When looking through your 2 (or 3 or 4) leftmost/rightmost points, find the one with the y-value closest to this average y-value.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21