Class CompoundPixelwiseFilter

  • All Implemented Interfaces:
    java.awt.image.BufferedImageOp

    public final class CompoundPixelwiseFilter
    extends AbstractPixelwiseFilter
    A filter that can apply multiple AbstractPixelwiseFilters in sequence. Using this filter to combine multiple filters is faster than applying each filter in sequence because it avoids the overhead of unpacking and repacking the image data multiple times.

    In-place filtering: This class supports in-place filtering (the source and destination images may be the same).

    Author:
    Chris Jennings
    • Constructor Detail

      • CompoundPixelwiseFilter

        public CompoundPixelwiseFilter()
        Creates a new compound filter with an empty filter list. If the list is not changed, this filter will have the same effect as a CloneFilter.
      • CompoundPixelwiseFilter

        public CompoundPixelwiseFilter​(AbstractPixelwiseFilter... filters)
        Creates a new compound filter with the specified filter list.
        Parameters:
        filters - an array of filters to apply in sequence
    • Method Detail

      • getFilters

        public AbstractPixelwiseFilter[] getFilters()
        Returns a copy of the filter list as an array.
        Returns:
        the filters applied by this compound filter
      • setFilters

        public void setFilters​(AbstractPixelwiseFilter... filters)
        Sets the filters to be applied by this compound filter.
        Parameters:
        filters - an array of filters to apply in sequence
      • appendFilter

        public void appendFilter​(AbstractPixelwiseFilter filter)
        Appends a new filter to the current filter list, replacing the existing list.
        Parameters:
        filter - the new filter to append
      • getFilter

        public AbstractPixelwiseFilter getFilter​(int index)
        Returns the filter at the specified index in the list of filters.
        Parameters:
        index - the index in the filter list, from 0 to getSize()-1.
        Returns:
        the filter at the specified index
      • getSize

        public int getSize()
        Returns the number of filters that will be applied by this compound filter.
        Returns:
        the number of filters in the list
      • filterPixels

        public void filterPixels​(int[] argb,
                                 int start,
                                 int end)
        Description copied from class: AbstractPixelwiseFilter
        This method is called with a block of ARGB values to be filtered. Subclasses must override this method to implement the actual filtering algorithm by replacing each pixel value in the range argb[start] ... argb[end-1] with the filtered value.
        Specified by:
        filterPixels in class AbstractPixelwiseFilter
        Parameters:
        argb - an array of pixel data to filter
        start - the index of the first pixel to filter
        end - the index of the last pixel to filter, plus one
      • workFactor

        protected float workFactor()
        Description copied from class: AbstractPixelwiseFilter
        Returns a factor representing the amount of work performed by this filter relative to a filter that simply copies the source image by reading and writing each pixel. For example, a filter that implemented a 3x3 convolution might return the value 9. The work factor value helps determine when an image should be processed in parallel. (There is significant overhead involved in running a filter in parallel, so it is only worth doing if the image is relatively large or the amount of processing per pixel is relatively high.)

        Note: The work factor may vary depending on the current filter settings.

        Overrides:
        workFactor in class AbstractPixelwiseFilter
        Returns:
        the approximate amount of work per pixel, relative to simply copying the pixel values