I have a "sugarcane crop" image taken from above (with a Drone) which was pre-processed with the MorphologicalPerimeter and EdgeDetection functions of Mathematica, resulting in binary image with a series of features for which I'd like to find/place some path-lines with specific parameters. Here is the original image:
With some simple image processing functions within Mathematica, I generated the following picture:
EdgeDetect[MorphologicalPerimeter[
ColorSeparate[aImg][[1]], 0.35], 20]
The idea is to find all the free paths between the series of shapes such that they appear like "streets" for the shapes. In other words, the lines should only be drawn over the black background, never touching or crossing the white features (unless that is impossible). The spacing in between the lines should be almost constant, but may vary slightly from one street to the next. In this example they will be almost straight lines, but that is not necessarily the general case, for the "streets" may curve as well.
Here is a bad example of what a result would be. It is a bad example because the lines are evenly spaced, and therefore they end up going over the white features in the image, which shouldn't be allowed. But it illustrates what is to be achieved. Look at the left lower corner of the image to see what is expected for the solution.
To me, this looks like an AI / Computer Vision problem, but I am wondering whether someone would give me a clever Mathematica idea for a starting point to solve this problem in an efficient manner. Bear in mind that in reality I will be dealing with images a lot larger that this.
An alternative solution is to draw the path-lines exactly over the white features, maximizing the "crossings" over the features, creating a series of "sugar cane lines" with as evenly spacing as possible. Please, refer only to the left lower corner of the image below for an idea of the alternate solution.
These two problems seem to be dual, and either solution suffices. Any help will be greatly appreciated.
I am adding information here as I manage to get better preprocessed images. For instance,
EdgeDetect[GradientFilter[
MorphologicalPerimeter[ColorSeparate[aImg][[1]], 0.35], 1], 20]
gives me a very nice preprocessed image,
which I can then add to the original image just to show off the nice results:
(source: dccs.com.br)
However, none of this helps me in determining the best paths for the "street" lines, not to mention that they should not be considered to be straight lines. They just happen to be in this example.
Here goes an original image with the suggested curved path. Unfortunately, in this case, the sugarcane is still in its infancy, but it represents a real case problem which should be dealt with. Thanks.
ImageLines
.GaborFilter
might be useful too. $\endgroup$WatershedComponents
(see under Neat Examples). Maybe some similar technique can be applied here as well. $\endgroup$