Class OilPaintingFilter

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

    public class OilPaintingFilter
    extends AbstractImagewiseFilter
    A filter that simulates oil painting. The filter takes two parameters, smear radius and a number of colour levels. The smear radius determines the size of the "paint daubs", and the levels setting controls the amount of colour variation allowed within a daub. Note that setting the number of levels to a value greater than 2smearRadius will not produce a noticeable difference in the result.

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

    Author:
    Chris Jennings
    • Constructor Detail

      • OilPaintingFilter

        public OilPaintingFilter()
      • OilPaintingFilter

        public OilPaintingFilter​(int levels,
                                 int smearRadius)
    • Method Detail

      • getLevels

        public int getLevels()
        Returns the number of channel levels to use.
        Returns:
        the number of levels
      • setLevels

        public void setLevels​(int levels)
        Sets the number of channel levels to use. The greater the number of levels, the more varied the image can be within a given smear radius.
        Parameters:
        levels - the levels to set
      • getSmearRadius

        public int getSmearRadius()
        Returns the number of rows and columns of pixel data around each source pixel are used to compute the destination pixel.
        Returns:
        the smear radius
      • setSmearRadius

        public void setSmearRadius​(int radius)
        Sets the number of rows and columns of pixel data around each source pixel that are used to compute the destination pixel.
        Parameters:
        radius - the smear radius to set
      • workFactor

        protected float workFactor()
        Description copied from class: AbstractImagewiseFilter
        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 AbstractImagewiseFilter
        Returns:
        the approximate amount of work per pixel, relative to simply copying the pixel values
      • filterPixels

        protected void filterPixels​(int[] srcPixels,
                                    int[] dstPixels,
                                    int width,
                                    int height,
                                    int y0,
                                    int rows)
        Description copied from class: AbstractImagewiseFilter
        Filters a block of rows in the source image, placing the result in the corresponding rows in the destination image. The block of rows to be filtered runs from y0 to y0 + rows-1 (inclusive).
        Specified by:
        filterPixels in class AbstractImagewiseFilter
        Parameters:
        srcPixels - the pixel data for the source image
        dstPixels - the destination for output pixels
        width - the width of the image
        height - the height of the image
        y0 - the index of the first row to filter
        rows - the number of rows to filter