forked from processing-js/processing-js.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPImage_filter_.html
More file actions
84 lines (79 loc) · 2.77 KB
/
Copy pathPImage_filter_.html
File metadata and controls
84 lines (79 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
---
layout: default
---
<table cellpadding="0" cellspacing="0" border="0" class="ref-item">
<tr>
<th scope="row">Class</th>
<td>PImage</td>
</tr>
<tr class="name-row">
<th scope="row">Name</th>
<td><h3>filter()</h3></td>
</tr>
<tr class="">
<th scope="row">Examples</th>
<td><div class="example"><img src="/reference/filter_.jpg" alt="example pic" /><pre class="margin">// @pjs preload must be used to preload the image
/* @pjs preload="archcrop.jpg"; */
PImage a;
a = loadImage("archcrop.jpg");
image(a, 0, 0);
a.filter(GRAY);
image(a, 50, 0);</pre></div>
<div class="example"><img src="/reference/filter_2.gif" alt="example pic" /><pre class="margin">// @pjs preload must be used to preload the image
/* @pjs preload="archcrop.jpg"; */
PImage a, b;
a = loadImage("archcrop.jpg");
b = loadImage("archcrop.jpg");
a.filter(THRESHOLD, .6);
image(a, 0, 0);
b.filter(THRESHOLD, .4);
image(b, 50, 0);</pre></div>
</td>
</tr>
<tr class="">
<th scope="row">Description</th>
<td><p>Filters an image as defined by one of the following modes:</p>
<p>THRESHOLD - converts the image to black and white pixels depending if they are above or below the threshold defined by the level parameter.
The level must be between 0.0 (black) and 1.0(white). If no level is specified, 0.5 is used.</p>
<p>GRAY - converts any colors in the image to grayscale equivalents</p>
<p>INVERT - sets each pixel to its inverse value</p>
<p>POSTERIZE - limits each channel of the image to the number of colors specified as the level parameter</p>
<p>BLUR - executes a Guassian blur with the level parameter specifying the extent of the blurring.
If no level parameter is used, the blur is equivalent to Guassian blur of radius 1.</p>
<p>OPAQUE - sets the alpha channel to entirely opaque.</p>
<p>ERODE - reduces the light areas with the amount defined by the level parameter.</p>
<p>DILATE - increases the light areas with the amount defined by the level parameter</p></td>
</tr>
<tr class="">
<th scope="row">Syntax</th>
<td><pre><kbd>img</kbd>.filter(<kbd>MODE</kbd>)</pre><br />
<pre><kbd>img</kbd>.filter(<kbd>MODE</kbd>,<kbd>srcImg</kbd>)</pre></td>
</tr>
<tr class="">
<th scope="row">Parameters</th>
<td>
<table cellpadding="0" cellspacing="0" border="0">
<tr class="">
<th scope="row">img</th>
<td>PImage: any variable of type PImage</td>
</tr>
<tr class="">
<th scope="row">MODE</th>
<td>Either THRESHOLD, GRAY, INVERT, POSTERIZE, BLUR, OPAQUE, ERODE, or DILATE</td>
</tr>
<tr class="">
<th scope="row">param</th>
<td>int or float in the range from 0 to 1</td>
</tr>
</table>
</td>
</tr>
<tr class="">
<th scope="row">Returns</th>
<td>None</td>
</tr>
<tr class="">
<th scope="row">Usage</th>
<td>Web & Application</td>
</tr>
</table>