# Detecting and measuring planting gaps (precision agriculture)

Tags: #<Tag:0x00007fd543fd7e68> #<Tag:0x00007fd543fd7c10>

#1

After the great success of the Oil palm trees counting thread (Thanks Anna and others), I am here asking for another help with UAV imagery in precision agriculture.
Giving a proper orthomosaic of a plantation (RGB or NDVI), I want the software to detect and measure plantation lines and plantation gaps, I attach a picture to better explain but don’t consider the low quality, i still have to do the orthofoto.
Do you think is possible with ImageJ?
Thank you very much

Oil palm tree counting
#2

Hi Lanzo,

what exactly would you like to measure, e.g. percentage of gaps per line?
In general you need two steps: 1) segment your trees and b) detect your plantation lines.

For segmentation of the trees I tried converting to HSB-stack, slight morphological closing (MorphoLibJ needed) and then thresholding:

``````run("HSB Stack");
run("Duplicate...", "title=Brightness duplicate range=3-3");
run("Invert");
``````

I then searched for a solution to automatically identify the individual plantation lines. I automatically determined the median distance between lines (in this image around 38 pixels) and then was thinking to shift a user-drawn poly-line by this value. This does not work well because of non-regular distances between and unregular shape of the plantation lines in the image.

So for now I can only think of rather ugly manual approaches:
To get the percentage of gaps:

1. Manually draw a poly-line along one plantation of linewidth 1 in the binary image.
2. Measure Integrated Density and Area. Ratio of gap/plantation line is: Integrated Density/Area*255

To count the number of non-gaps:

1. Manually draw a poly-line along one plantation of linewidth 25 in the binary image.
2. `run("Line to Area");`
3. `run("Analyze Particles...", "size=5-Infinity summarize add");`

Cheers
Anna

#3

Hello Lanzo,

Here is a paper that deals with your situation using QGIS and R. Still is not totally automatic but it gives good results:

I hope it helps. Best regards,
Ernesto

#4

Sorry for no reply, I am far from home, as soon as possible I will check everything, thank you very much