Class TLcdMedianOp

java.lang.Object
com.luciad.imaging.operator.ALcdImageOperator
com.luciad.imaging.operator.TLcdMedianOp

public final class TLcdMedianOp extends ALcdImageOperator
Applies a median filter to an image.

The median filter computes for each pixel the median in a small area surrounding it. The median is the value that is 'in the middle' when the values would put into a sorted list. For example the median of [3, 5, 2, 1, 4] is 3: 2 values are smaller ([1, 2]) and 2 values are larger ([4, 5]).

If one of the input pixels has a "no data" value, the result is also "no data".

This operator expects kernels with odd dimensions (e.g., 3x3). Otherwise an IllegalArgumentException will be thrown.

Example


 // Using the static method:
 ALcdImage inputImage = ...;
 ALcdImage outputImage = TLcdMedianOp.median(inputImage, 3, 3);

 // Using a data object:
 ALcdImage inputImage = ...;
 TLcdMedianOp op = new TLcdMedianOp();
 ILcdDataObject params = op.getParameterDataType().newInstance();
 params.setValue(TLcdMedianOp.INPUT_IMAGE, inputImage);
 params.setValue(TLcdMedianOp.MASK_WIDTH, 3);
 params.setValue(TLcdMedianOp.MASK_HEIGHT, 3);
 outputImage = op.apply(params);
 
Input
Output
Since:
2015.1
  • Field Details

    • NAME

      public static final String NAME
      Name of the operator.
      See Also:
    • INPUT_IMAGE

      public static final TLcdDataProperty INPUT_IMAGE
      The input image.
    • MASK_WIDTH

      public static final TLcdDataProperty MASK_WIDTH
      Width of the median filter.
    • MASK_HEIGHT

      public static final TLcdDataProperty MASK_HEIGHT
      Height of the median filter.
    • MEDIAN_FILTER_TYPE

      public static final TLcdDataType MEDIAN_FILTER_TYPE
      Input data type of the operator.
  • Constructor Details

    • TLcdMedianOp

      public TLcdMedianOp()
      Default constructor.
  • Method Details

    • apply

      public ALcdImage apply(ILcdDataObject aParameters)
      Description copied from class: ALcdImageOperator
      Applies this operator to the given input parameters. The parameters are stored in a data object which must be of the type given by ALcdImageOperator.getParameterDataType().
      Specified by:
      apply in class ALcdImageOperator
      Parameters:
      aParameters - the parameters for the operator
      Returns:
      the image produced by the operator
    • median

      public static ALcdImage median(ALcdImage aImage, int aMaskWidth, int aMaskHeight)
      Applies a median filter to the given image.
      Parameters:
      aImage - the image to be median
      aMaskWidth - the width of the median filter
      aMaskHeight - the height of the median filter
      Returns:
      the median image