org.geotools.coverage.processing.operation
Class GradientMagnitude

Object
  extended by AbstractOperation
      extended by Operation2D
          extended by OperationJAI
              extended by GradientMagnitude
All Implemented Interfaces:
Serializable, Operation

public class GradientMagnitude
extends OperationJAI

Edge detector which computes the magnitude of the image gradient vector in two orthogonal directions. The result of the "GradientMagnitude" operation may be defined as:

dst[x][y][b] = sqrt( SH(x,y,b)2 + SV(x,y,b)2) × scale

where SH(x,y,b) and SV(x,y,b) are the horizontal and vertical gradient images generated from band b of the source image by correlating it with the supplied orthogonal (horizontal and vertical) gradient masks.

Before to compute the gradients, the kernels are tested against artificials horizontal and vertical gradients of one unit of sample / unit of localization. For example:

Kernels are normalized by dividing all their coefficients by the result of this test. In other words, kernels are normalized in such a way that applying the "GradientMagnitude" operation on a horizontal or vertical gradient of 1 such "geophysical" units will give a result of 1. This is an attempt to give geophysical meaning to the numbers produced by the "GradientMagnitude" operation. This normalization depends of the coverage's grid geometry.

NOTE: When the masks are symetric (e.g. Sobel, Prewitt (or Smoothed), isotropic, etc.), then the above-cited algorithm produces the same result than the "normalization factor" × "spatial factor" published by:

Simpson, J.J. (1990), "On the accurate detection and enhancement of oceanic features observed in satellite data" in Remote sensing environment, 33:17-33.
However, for non-symetric masks (e.g. Kirsch), then a difference is found.

Name: "GradientMagnitude"
JAI operator: "GradientMagnitude"
Parameters:

Name Class Default value Minimum value Maximum value
"Source" GridCoverage2D N/A N/A N/A
"Mask1" KernelJAI KernelJAI.GRADIENT_MASK_SOBEL_HORIZONTAL N/A N/A
"Mask2" KernelJAI KernelJAI.GRADIENT_MASK_SOBEL_VERTICAL N/A N/A

Since:
2.2
Author:
Martin Desruisseaux (IRD)
See Also:
Operations.gradientMagnitude(org.opengis.coverage.Coverage), GradientMagnitudeDescriptor, Serialized Form
Module:

Nested Class Summary
 
Nested classes/interfaces inherited from class OperationJAI
OperationJAI.Parameters
 
Field Summary
 
Fields inherited from class OperationJAI
operation, RENDERED_MODE
 
Fields inherited from class Operation2D
PRIMARY_SOURCE_INDEX, SOURCE_0
 
Fields inherited from class AbstractOperation
descriptor
 
Constructor Summary
GradientMagnitude()
          Constructs a default gradient magnitude operation.
 
Method Summary
protected  Category deriveCategory(Category[] categories, OperationJAI.Parameters parameters)
          Derives the quantitative category for a band in the destination image.
protected  GridCoverage2D deriveGridCoverage(GridCoverage2D[] sources, OperationJAI.Parameters parameters)
          Applies the operation on grid coverage.
protected  Unit deriveUnit(Unit[] units, OperationJAI.Parameters parameters)
          Derives the unit of data for a band in the destination image.
 
Methods inherited from class OperationJAI
createRenderedImage, deriveName, deriveRange, deriveSampleDimension, doOperation, equals, getJAI, getOperationDescriptor, getProperties, getQuantitative, prepareParameters, resampleToCommonGeometry
 
Methods inherited from class Operation2D
computeOnGeophysicsValues, extractSources, getFactory
 
Methods inherited from class AbstractOperation
ensureNonNull, getDescription, getDocURL, getName, getNumSources, getParameters, getProcessor, getVendor, getVersion, hashCode, toString
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GradientMagnitude

public GradientMagnitude()
Constructs a default gradient magnitude operation.

Method Detail

deriveGridCoverage

protected GridCoverage2D deriveGridCoverage(GridCoverage2D[] sources,
                                            OperationJAI.Parameters parameters)
Applies the operation on grid coverage. The default implementation looks for kernels specified in the parameter block and divide them by the distance between pixels, in the grid coverage's coordinate reference system.

Overrides:
deriveGridCoverage in class OperationJAI
Parameters:
sources - The source coverages.
parameters - Parameters, rendering hints and coordinate reference system to use.
Returns:
The result as a grid coverage.
See Also:
OperationJAI.doOperation(org.opengis.parameter.ParameterValueGroup, org.geotools.factory.Hints), OperationJAI.deriveSampleDimension(org.geotools.coverage.GridSampleDimension[][], org.geotools.coverage.processing.OperationJAI.Parameters), JAI.createNS(java.lang.String, java.awt.image.renderable.ParameterBlock, java.awt.RenderingHints)

deriveCategory

protected Category deriveCategory(Category[] categories,
                                  OperationJAI.Parameters parameters)
Derives the quantitative category for a band in the destination image. This implementation computes the expected gradient range from the two masks and the value range in the source grid coverage.

Overrides:
deriveCategory in class OperationJAI
Parameters:
categories - The quantitative categories from every sources. For unary operations like "GradientMagnitude", this array has a length of 1. For binary operations like "add" and "multiply", this array has a length of 2.
parameters - Parameters, rendering hints and coordinate reference system to use.
Returns:
The quantitative category to use in the destination image, or null if unknown.

deriveUnit

protected Unit deriveUnit(Unit[] units,
                          OperationJAI.Parameters parameters)
Derives the unit of data for a band in the destination image. This method compute sample/axis where:

Overrides:
deriveUnit in class OperationJAI
Parameters:
units - The units from every sources. For unary operations like "GradientMagnitude", this array has a length of 1. For binary operations like "add" and "multiply", this array has a length of 2.
parameters - Parameters, rendering hints and coordinate reference system to use.
Returns:
The unit of data in the destination image, or null if unknow.


Copyright © 1996-2009 Geotools. All Rights Reserved.