Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I don't know if exist a magic way to to this but you could try with contours.

  1. Extract the outer profile segments as a contours
  2. For each contour end point (pt0) search a contour that start around a current end point (pt1)
  3. You got the space as pt0->pt1 and that is 1st side of your rectangle
  4. Calculate the angle pt0->pt1
  5. Search the inner profile in angle+90 and angle-90 to get 3rd and 4th point of your rectangle. (Or align the a small area of the image arounf pt0 and pt1 and search the inner profile up and down)

I don't know if exist a magic way to to this but you could try with contours.

  1. Extract the outer profile segments as a contours
  2. For each contour end point (pt0) search a contour that start around a current end point (pt1)
  3. You got the space as pt0->pt1 and that is 1st side of your rectangle
  4. Calculate the angle pt0->pt1
  5. Search the inner profile in angle+90 and angle-90 to get 3rd and 4th point of your rectangle. (Or align the a small area of the image arounf around pt0 and pt1 and search the inner profile up and down)