Transforms pixels in this image using
kernel,
which should be an array of numbers that determine how a pixel and
its neighbors are combined to produce a new pixel,
and returns this image to the caller.
The optional
edge
argument should be
EDGE_ZERO_FILL
or
EDGE_NO_OP,
which are constants defined in
yoix.image,
that determine what happens to pixels near the edges that do not have
all the neighbors required by the
kernel
array.
The
kernel
is currently assumed to be a square array of numbers,
a restriction may be lifted in a future release,
but for now any extra values will be silently ignored.
| |
| Example: |
The program,
import yoix.*.*;
Array blur_kernel = {
.1, .1, .1,
.1, .1, .1,
.1, .1, .1,
};
Array edge_kernel = {
0, -1, 0,
-1, 4, -1,
0, -1, 0,
};
Image img = {
String source = "http://www.yoix.org/imgs/ATTlogo.gif";
Array metrics = {0, 0, 1.0, 1.0};
};
Image img_blurred = {
Image source = img;
Array metrics = {0, 0, 1.0, 1.0};
paint() {
convolve(blur_kernel);
}
};
Image img_edge = {
Image source = img;
Array metrics = {0, 0, 1.0, 1.0};
paint() {
convolve(edge_kernel, EDGE_NO_OP);
}
};
JFrame f = {
paint(Rectangle r) {
graphics {
rectclip(r);
moveto(72, 72);
showimage(img);
showimage(img_blurred);
showimage(img_edge);
initclip();
}
}
};
f.visible = TRUE;
defines a simple kernel that can detect edges and another
one that blurs and darkens a bit.
Notice how the
metrics
arrays defined in the images control where showimage, which is defined in
Graphics,
places them.
| | |
| Return: |
Image
| | |
| See Also: |
convert,
getpixel,
replace,
rescale,
setpixel,
transform
|
|