This task finds rows within an ENVIAgCrops object, removes crops that are outside the rows, and creates a classification raster with the remaining crop locations and sizes. It optionally creates polyline and polygon regions of interest (ROIs) centered over each row. You must run ENVIAgCropCount, AgCropCount Task, or AgCountAndRasterizeCrops Task first before running this task.

This task requires a separate license for the ENVI Crop Science Module; contact your sales representative for more information.

Example


This example performs the following steps:

  1. Opens an RGB image of emerging cotton plants, captured by an unmanned aerial vehicle (UAV). Image courtesy of Drone Global Network.
  2. Runs AgCropCount Task on the green band of the image, to count the crops and to create an ENVIAgCrops object.
  3. Finds rows within the crops object, removes crops that are outside the rows, and creates a classification raster with the remaining crop locations and sizes.
  4. Displays the input image, the crops raster (with outliers removed), and the row polyline ROI.
; Start the application
e = ENVI()
 
; Open an input file
File = Filepath('Cotton.dat', $
  SUBDIR=['data','crop_science'], $
  ROOT_DIR=e.Root_Dir)
Raster = e.OpenRaster(File)
 
; Process the green band
subset = ENVISubsetRaster(Raster, BANDS=[1])
 
; Count the crops
countTask = ENVITask('AgCropCount')
countTask.INPUT_RASTER = subset
countTask.INCLUDE_EDGES ='true'
countTask.MINIMUM_CROP_DIAMETER = 9 ;pixels
countTask.MAXIMUM_CROP_DIAMETER = 12
countTask.NUMBER_OF_INCREMENTS= 12
countTask.GAUSSIAN_FACTOR = 0.8
countTask.PERCENT_OVERLAP = 60
countTask.INTENSITY_THRESHOLD = 0.81
countTask.Execute
 
; Find rows and remove outliers
Task = ENVITask('AgFindRowsAndRemoveOutliers')
Task.INPUT_CROPS = countTask.OUTPUT_CROPS
Task.DISTANCE_THRESHOLD = 14.5 ;pixels
Task.INLIER_FRACTION = 0.7
Task.MINIMUM_CROPS_PER_ROW = 25
Task.MAXIMUM_SLOPE = 2.0
Task.FILLED = 'true'
Task.Execute
 
; Display the result
View = e.GetView()
Layer1 = View.CreateLayer(subset)
Layer2 = View.CreateLayer(Task.OUTPUT_RASTER)
roiLayer = Layer2.AddROI(Task.OUTPUT_ROW_ROIS[0])
View.Zoom, /FULL_EXTENT
 
Print, 'Number of outliers removed: ', Task.OUTPUT_NREMOVED
Print, 'Number of rows found: ', Task.OUTPUT_NROWS

Syntax


Result = ENVITask('AgFindRowsAndRemoveOutliers')

Input properties (Set, Get): DISTANCE_THRESHOLD, FILLED, INLIER_FRACTION, INPUT_CROPS, MAXIMUM_SLOPE, MINIMUM_CROPS_PER_ROW, OUTPUT_CROPS_URI, OUTPUT_RASTER_URI, OUTPUT_REMOVED_CROPS_URI, OUTPUT_ROWS_ROIS_URI, ROW_ANGLE, ROW_SPACING

Output properties (Get only): OUTPUT_CROPS, OUTPUT_NCROPS, OUTPUT_NREMOVED, OUTPUT_NROWS, OUTPUT_RASTER, OUTPUT_REMOVED_CROPS, OUTPUT_ROW_ROIS

Properties marked as "Set" are those that you can set to specific values. You can also retrieve their current values any time. Properties marked as "Get" are those whose values you can retrieve but not set.

Methods


This task inherits the following methods from ENVITask:

AddParameter

Execute

Parameter

ParameterNames

RemoveParameter

Properties


This task inherits the following properties from ENVITask:

COMMUTE_ON_DOWNSAMPLE

COMMUTE_ON_SUBSET

DESCRIPTION

DISPLAY_NAME

NAME

REVISION

TAGS

This task also contains the following properties:

DISTANCE_THRESHOLD (optional)

Specify a distance threshold value in meters. The task calculates the distance from each crop center to the row line. It removes crops from that row if the distance is greater than the DISTANCE_THRESHOLD value that you provide. If you do not specify a value, the distance threshold is one-third of the row spacing, by default. If the input crops object does not have a spatial reference, enter the distance in pixels.

FILLED (optional)

Set this property to true to create filled circles in the output crops classification raster. The default is false.

INLIER_FRACTION (optional)

Specify a value ranging from 0 to 1.0. This is the fraction of candidate crops that each row should consist of, to be considered a valid row. The default value is 0.5 (50%). If the crops object has too many outliers, the tool will not correctly filter them out. In this case, set INLIER_FRACTION to a higher fraction to remove more outliers. If the rows vary greatly in the number of crops they contain, then set this parameter to a smaller fraction. Increase this value if there are many outliers and they are being identified as false rows. If the rows vary greatly from the rows surrounding them (not gradually across the field), then set this parameter to a smaller fraction. This parameter can be used in conjunction with MINIMUM_CROPS_PER_ROW, which sets an absolute minimum for all rows. For instance, say a field gradually varies from 50 crops per row on the left to 20 crops per row on the right. With the default fraction of 0.5, rows on the left must have at least 25 crops and rows on the right must have at least 10. If there are many outliers and there are false rows with more than 25 crops on the left and 10 on the right, the inlier fraction can be increased to exclude them. On the other hand, if there was a single valid row of 20 crops on the left (next to the rows of 50), an inlier fraction of 0.5 would exclude it and the fraction would have to be lowered.

INPUT_CROPS (required)

Specify an input ENVIAgCrops object.

MAXIMUM_SLOPE (optional)

Specify the maximum amount (in degrees) that the slope of a row line can differ from the primary direction that the algoritihm initially determined. For example, if the field direction is 45 degrees and you specify a value of 1, then the row lines can have a slope of 44 to 46 degrees to be valid. The default value is 2 degrees.

MINIMUM_CROPS_PER_ROW (optional)

Specify the number of crops required to be considered a row. The minimum number is 2, and the default is 3.

OUTPUT_CROPS

This is a reference to the output crop data, after outliers have been removed.

OUTPUT_CROPS_URI (optional)

Specify a string with the fully qualified path and filename for OUTPUT_CROPS. If you do not specify this property, the output crop file is only temporary. Once the crop file has no remaining references, ENVI deletes the temporary file.

OUTPUT_NCROPS

This is the output number of crops, after outliers have been removed.

OUTPUT_NREMOVED

This is the number of crops removed because they did not belong in a row.

OUTPUT_NROWS

This is the number of crop rows found.

OUTPUT_RASTER

This is a reference to the output crops classification raster.

OUTPUT_RASTER_URI (optional)

Specify a string with the fully qualified filename and path of the associated OUTPUT_RASTER. If you do not specify this property, or set it to an exclamation symbol (!), a temporary file will be created.

OUTPUT_REMOVED_CROPS

This is a reference to the output ENVIAgCrops object containing the removed crops.

OUTPUT_REMOVED_CROPS_URI (optional)

Specify a string with the fully qualified filename and path for the output JSON file that will contain the removed crops.

OUTPUT_ROW_ROIS

This is a reference to an output array of ROIs identifying the crop rows.

OUTPUT_ROW_ROI_URI (optional)

Specify a string with the fully qualified filename and path for the output XML file containing the crop row ROIs.

ROW_ANGLE (optional)

The row angle is calculated automatically. To override it, specify the primary angle of the rows in degrees clockwise from 0, where a value of 0 represents a horizontal alignment of the field.

ROW_SPACING (optional)

The spacing between the rows is calculated automatically. To override it, specify the row spacing in meters. If the input ENVIAgCrops object does not have a spatial reference, specify the spacing in pixels.

Version History


Crop Science 1.0.1

Introduced

Crop Science 1.1.1

Added ROW_ANGLE and ROW_SPACING properties

See Also


AgCropCount Task, AgFindAndRasterizeCropGaps Task