Package ca.cgjennings.graphics.filters
Class OilPaintingFilter
- java.lang.Object
-
- ca.cgjennings.graphics.filters.AbstractImageFilter
-
- ca.cgjennings.graphics.filters.AbstractImagewiseFilter
-
- ca.cgjennings.graphics.filters.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 Summary
Constructors Constructor Description OilPaintingFilter()
OilPaintingFilter(int levels, int smearRadius)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
filterPixels(int[] srcPixels, int[] dstPixels, int width, int height, int y0, int rows)
Filters a block of rows in the source image, placing the result in the corresponding rows in the destination image.int
getLevels()
Returns the number of channel levels to use.int
getSmearRadius()
Returns the number of rows and columns of pixel data around each source pixel are used to compute the destination pixel.void
setLevels(int levels)
Sets the number of channel levels to use.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.protected float
workFactor()
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.-
Methods inherited from class ca.cgjennings.graphics.filters.AbstractImagewiseFilter
filter, filter
-
Methods inherited from class ca.cgjennings.graphics.filters.AbstractImageFilter
clamp, clamp, clamp, clampBoth, createCompatibleDestImage, fA, fB, fG, fR, getARGB, getARGB, getARGBSynch, getBounds2D, getPoint2D, getRenderingHints, iA, iB, iG, iR, setARGB, setARGB, setARGBSynch
-
-
-
-
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 classAbstractImagewiseFilter
- 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 classAbstractImagewiseFilter
- Parameters:
srcPixels
- the pixel data for the source imagedstPixels
- the destination for output pixelswidth
- the width of the imageheight
- the height of the imagey0
- the index of the first row to filterrows
- the number of rows to filter
-
-