AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YChart | YDAT | YWAIT | Byzgraf | FAQs
replace (Array table, ...) typedict.Image
 
Uses table, which usually is an array of 256 integers that have values between 0 and 255, as a lookup table that maps the color components of each pixel in this image into new values, and returns this image to the caller. One argument tells replace to use table to map all the color components in this image. Two or more arguments means replace only touches the first argc color components, where argc is the number of arguments in the call. NULL tables are allowed and mean the selected color components will not be changed.
 
 Example:   The program,
import yoix.*.*;

Array toss[256];
Array dark[256];
Array keep[256];

for (n = 0; n < 256; n++) {
    toss[n] = 0;
    keep[n] = n;
    dark[n] = n/2;
}

Image img = {
    String source = "http://www.yoix.org/imgs/ATTlogo.gif";
    Array  metrics = {0, 0, 1.0, 1.0};
};

Image img_dark = {
    Image source = img;
    Array metrics = {0, 0, 1.0, 1.0};

    paint() {
        replace(dark);
    }
};

Image img_blue = {
    Image source = img;
    Array metrics = {0, 0, 1.0, 1.0};

    paint() {
        replace(toss, toss, keep);
    }
};

JFrame f = {
    paint(Rectangle r) {
        graphics {
            rectclip(r);
            moveto(72, 72);
            showimage(img);
            showimage(img_dark);
            showimage(img_blue);
            initclip();
        }
    }
};

f.visible = TRUE;
uses replace to darken one image and extract the blue color component in another. Notice how the metrics arrays defined in the images control where showimage, which is defined in Graphics, places them.
 
 Return:   Image
 
 See Also:   convert, convolve, getpixel, rescale, setpixel, transform

 

Yoix is a registered trademark of AT&T Inc.