2
$\begingroup$

I want to find the contours of (parts) image and sent the output to a laser cutter. For example, take this image:

enter image description here

I use this code:

maskv1 = AlphaChannel[RemoveBackground[bal1]];
 contours =  
 ImageMeasurements[   EdgeDetect[Blur[ImageMultiply[bal1, maskv1], 2],
 1], "Contours"]; bal4 = ImageGraphics[   ColorNegate[   
 DeleteSmallComponents[
     Dilation[
      EdgeDetect[BilateralFilter[Graphics[contours], 7, .1]], .6], 
     Method -> "Mean"]], ImageSize -> 600];

The output is:

enter image description here

The red line is done by myself. As you can see, the contour is not closed. The desired output is something like:

enter image description here

So I need a function to close the outline/contour. Who has a suggestion to do this?

$\endgroup$
3
$\begingroup$
img = Import["https://i.stack.imgur.com/O14tf.jpg"]

Using ImageMesh + BoundingRegion:

mindisk = BoundingRegion[ImageMesh[RemoveBackground@img], "MinDisk"]
Disk[{56.0259, 59.0719}, 48.1942]
Show[img, Graphics[{FaceForm[], EdgeForm[{Red, Thick}], mindisk}]]

enter image description here

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.