This reference is for Processing 3.0+. If you have a previous version, use the reference included with your software in the Help menu. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.
Class | |||||||
---|---|---|---|---|---|---|---|
Name | filter() |
||||||
Examples | PImage img1, img2; void setup() { size(100, 100); img1 = loadImage("apples.jpg"); img2 = loadImage("apples.jpg"); img1.filter(THRESHOLD, 0.3); img2.filter(THRESHOLD, 0.7); } void draw() { image(img1, 0, 0); image(img2, width/2, 0); } PImage img1, img2; void setup() { img1 = loadImage("apples.jpg"); img2 = loadImage("apples.jpg"); img2.filter(GRAY); } void draw() { image(img1, 0, 0); image(img2, width/2, 0); } PImage img1, img2; void setup() { img1 = loadImage("apples.jpg"); img2 = loadImage("apples.jpg"); img2.filter(INVERT); } void draw() { image(img1, 0, 0); image(img2, width/2, 0); } PImage img1, img2; void setup() { img1 = loadImage("apples.jpg"); img2 = loadImage("apples.jpg"); img2.filter(POSTERIZE, 4); } void draw() { image(img1, 0, 0); image(img2, width/2, 0); } PImage img1, img2; void setup() { img1 = loadImage("apples.jpg"); img2 = loadImage("apples.jpg"); img2.filter(BLUR, 6); } void draw() { image(img1, 0, 0); image(img2, width/2, 0); } PImage img1, img2; void setup() { img1 = loadImage("apples.jpg"); img2 = loadImage("apples.jpg"); img2.filter(ERODE); } void draw() { image(img1, 0, 0); image(img2, width/2, 0); } PImage img1, img2; void setup() { img1 = loadImage("apples.jpg"); img2 = loadImage("apples.jpg"); img2.filter(DILATE); } void draw() { image(img1, 0, 0); image(img2, width/2, 0); } | ||||||
Description |
Filters the image as defined by one of the following modes: THRESHOLD Converts the image to black and white pixels depending if they are above or below the threshold defined by the level parameter. The parameter must be between 0.0 (black) and 1.0 (white). If no level is specified, 0.5 is used. GRAY Converts any colors in the image to grayscale equivalents. No parameter is used. OPAQUE Sets the alpha channel to entirely opaque. No parameter is used. INVERT Sets each pixel to its inverse value. No parameter is used. POSTERIZE Limits each channel of the image to the number of colors specified as the parameter. The parameter can be set to values between 2 and 255, but results are most noticeable in the lower ranges. BLUR Executes a Gaussian blur with the level parameter specifying the extent of the blurring. If no parameter is used, the blur is equivalent to Gaussian blur of radius 1. Larger values increase the blur. ERODE Reduces the light areas. No parameter is used. DILATE Increases the light areas. No parameter is used. |
||||||
Syntax | pimg.filter(kind) pimg.filter(kind, param) | ||||||
Parameters |
| ||||||
Returns | void |
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.