title: OpenCv - Contours segments union
body: <p>first post here, I've been looking for a solution to solve a problem for days with no results and I ask you for help.
  I have enough experience with Python but little experience with OpenCV: I am trying to analyze and get a cutting line to trim a material excluding defects near contour.</p>
  <p>On the material image I've been able to obtain the outer contour and the inner contour (for cut) excluding defects near the edge.</p>
  <p>The internal contour, however, <strong>despite being perfect in recognizing defects,</strong> <strong>always leaves an offset even from the parts that should not be cut</strong>.</p>
  <p>I attach photos to make it clear: in red color outer edge (with defects), in yellow color inner edge to eliminate defects:</p>
  <p><strong><a href="https://i.stack.imgur.com/gEGq8.png" rel="nofollow noreferrer">outer and inner contours</a></strong></p>
  <p>In this photo there is an example of the outline I would like to obtain (sorry, done with paint):</p>
  <p><strong><a href="https://i.stack.imgur.com/1YkKQ.png" rel="nofollow noreferrer">inner contour aspected</a></strong></p>
  <p>I have tried several searches here and on internet to find ideas and I have studied different approaches (opencv, numpy, scipy, shapely) and in no case I've been able to get the desired results.</p>
  <p>In practice, my difficulty is recognize (I think should be a solution) the parallelism between the two contours (which, however, are very segmented), and then making the yellow contour coincide with the external red one when the distance between the two is less than an X value.</p>
  <p>Do you have any ideas on the approach to solve the problem?</p>
  <p>Thank you.</p>