org.geotools.coverage.processing.operation
Class GradientMagnitude

java.lang.Object
  extended byorg.geotools.coverage.processing.AbstractOperation
      extended byorg.geotools.coverage.processing.Operation2D
          extended byorg.geotools.coverage.processing.OperationJAI
              extended byorg.geotools.coverage.processing.operation.GradientMagnitude
All Implemented Interfaces:
org.opengis.coverage.processing.Operation, java.io.Serializable

public class GradientMagnitude
extends OperationJAI

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

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

where and 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 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 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
GridCoverage2D N/A N/A N/A
KernelJAI KernelJAI.GRADIENT_MASK_SOBEL_HORIZONTAL N/A N/A
KernelJAI KernelJAI.GRADIENT_MASK_SOBEL_VERTICAL N/A N/A

Since:
2.2
Version:
$Id: GradientMagnitude.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Martin Desruisseaux
See Also:
Operations.gradientMagnitude(org.opengis.coverage.Coverage), GradientMagnitudeDescriptor, Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.geotools.coverage.processing.OperationJAI
OperationJAI.Parameters
 
Field Summary
 
Fields inherited from class org.geotools.coverage.processing.OperationJAI
operation
 
Fields inherited from class org.geotools.coverage.processing.Operation2D
SOURCE_0
 
Fields inherited from class org.geotools.coverage.processing.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  javax.units.Unit deriveUnit(javax.units.Unit[] units, OperationJAI.Parameters parameters)
          Derives the unit of data for a band in the destination image.
 
Methods inherited from class org.geotools.coverage.processing.OperationJAI
computeOnGeophysicsValues, createRenderedImage, deriveName, deriveRange, deriveSampleDimension, doOperation, equals, getJAI, resampleToCommonGeometry
 
Methods inherited from class org.geotools.coverage.processing.Operation2D
getFactory, getGridCoverageProcessor
 
Methods inherited from class org.geotools.coverage.processing.AbstractOperation
ensureNonNull, getDescription, getDocURL, getName, getNumSources, getParameters, getProcessor, getVendor, getVersion, hashCode, toString
 
Methods inherited from class java.lang.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 , this array has a length of 1. For binary operations like and , this array has a length of 2.
parameters - Parameters, rendering hints and coordinate reference system to use.
Returns:
The quantative category to use in the destination image, or if unknow.

deriveUnit

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

Overrides:
deriveUnit in class OperationJAI
Parameters:
units - The units from every sources. For unary operations like , this array has a length of 1. For binary operations like and , 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 if unknow.


Copyright © GeoTools. All Rights Reserved.