I have a set of coordinates that I need a robot to draw, thus it must take the shortest path along these coordinates. Plotting them looks like this:
maskCoordinates is derived from the following code, which runs
ComponentMeasurements on any given image, and for this example works with the first mask:
intWidth = 100; imgCar = Import["https://2hire.io/wp-content/uploads/2016/12/car.png"]; imgCar = ColorConvert[imgCar, "Grayscale"]; imgCar = ImageResize[imgCar, intWidth]; edges = Thinning@EdgeDetect@imgCar; masks = ComponentMeasurements[edges, "Mask"]; maskCoordinates = PixelValuePositions[Image@masks[[1, 2]], 1];
I have tried using
FindShortestTour, but that only works for "complete" shapes/masks that I'm working with, like a circle. So applying this to the given mask, I get:
Which is close, but not exactly what I want. I thought that
FindShortestPath would get the job done, but haven't had any succes with that yet.