Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Faster method use connected componnet and find contours 1-Find all connected components by using find FindContour method 2-Store contour for every Region(Connected componnet CC) 3-calculate the Bounding Rect for every region (CC) 4-Loop in all region 5-For every region , find the nearest regions depending on the Bounding rect 6-now you have the suspected regions which can be connected to region, compare the two contours and find the mimimum distance between the two contours , if the minimum distance is smaller than threshould (say 10 pixel) then now you can draw line from Point1 in first contour and point2 in second contour , Point1 and Point2 are the points which satisfy the minmum distance calculated before. 7-repeat the proces for all regions

Faster method use connected componnet and find contours 1-Find contours

  1. Find all connected components by using find FindContour method 2-Store method
  2. Store contour for every Region(Connected componnet CC) 3-calculate CC)
  3. calculate the Bounding Rect for every region (CC) 4-Loop (CC)
  4. Loop in all region 5-For region
  5. For every region , find the nearest regions depending on the Bounding rect 6-now rect
  6. now you have the suspected regions which can be connected to region, compare the two contours and find the mimimum distance between the two contours , if the minimum distance is smaller than threshould (say 10 pixel) then now you can draw line from Point1 in first contour and point2 in second contour , Point1 and Point2 are the points which satisfy the minmum distance calculated before. 7-repeat before.
  7. repeat the proces for all regions

Faster method use connected componnet and find contours

  1. Find all connected components by using find FindContour method
  2. Store contour for every Region(Connected componnet CC)
  3. calculate the Bounding Rect for every region (CC)
  4. Loop in all region
  5. For every region , find the nearest regions depending on the Bounding rect
  6. now you have the suspected regions which can be connected to region, compare the two contours and find the mimimum distance between the two contours , if the minimum distance is smaller than threshould (say 10 pixel) then now you can draw line from Point1 in first contour and point2 in second contour , Point1 and Point2 are the points which satisfy the minmum distance calculated before.
  7. repeat the proces for all regions

EDIT: you can find sample implemention code here