Image Filter Object Agents

 

The architecture for the Image Filter LScript provides a mechanism for accessing and modifying image pixel data. The ImageFilter Object Agent is passed to the process() function of an Image Filter script if it is the only argument defined.

process: ifo

{
    …
}

Data Members

The following data members are exported by the ImageFilter

Object Agent:

width(READ-ONLY)
width is the width, in pixels, of the current buffer.

height (READ-ONLY)
height is the height, in pixels, of the current buffer.

frame (READ-ONLY)
frame is the current frame number for the image.

start (READ-ONLY)
start is the render start time for the image.

end (READ-ONLY)
end is the render end time for the image.

red[]
red[] represents the red-pixel buffer values for the image in floating-point format. Indexing is in [column,row] form.

green[ ]
green[ ] represents the green-pixel buffer values for the image in floating-point format. Indexing is in [column,row] form.

blue[]
blue[] represents the blue-pixel buffer values for the image in floating-point format. Indexing is in [column,row] form.

alpha[]
alpha[] represents the alpha-pixel buffer values for the image in floating-point format. Indexing is in [column,row] form.

special[ ](READ-ONLY)
special[] represents the special buffer values. Indexing is in [column,row] form.

luminous[ ]           (READ-ONLY)
luminous[] represents the luminous buffer values. Indexing is in [column,row] form.

diffuse[ ]              (READ-ONLY)
diffuse[] represents the diffuse buffer values. Indexing is in [column,row] form.

specular[ ]           (READ-ONLY)
specular[] represents the specular buffer values. Indexing is in [column,row] form.

mirror[ ]               (READ-ONLY)
mirror[] represents the mirror buffer values. Indexing is in [column,row] form.

trans[ ]                 (READ-ONLY)
trans[] represents the trans buffer values. Indexing is in [column,row] form.

rawred[ ]             (READ-ONLY)
rawred[] represents the rawred buffer values. Indexing is in [column,row] form.

rawgreen[ ]         (READ-ONLY)
rawgreen[] represents the rawgreen buffer values. Indexing is in [column,row] form.

rawblue[ ]            (READ-ONLY)
rawblue[] represents the rawblue buffer values. Indexing is in [column,row] form.

shading[ ]            (READ-ONLY)
shading[] represents the shading buffer values. Indexing is in [column,row] form.

shadow[ ]             (READ-ONLY)
shadow[] represents the shadow buffer values. Indexing is in [column,row] form.

geometry[ ]           (READ-ONLY)
geometry[] represents the geometry buffer values. Indexing is in [column,row] form.

depth[ ]                 (READ-ONLY)
depth[] represents the depth buffer values. Indexing is in [column,row] form.

diffshade[ ]            (READ-ONLY)
diffshade[] represents the diffshade buffer values. Indexing is in [column,row] form.

specshade[ ]          (READ-ONLY)
specshade[] represents the specshade buffer values. Indexing is in [column,row] form.

motionx[ ]             (READ-ONLY)
motionx[] represents the motionx buffer values. Indexing is in [column,row] form.

motiony[ ]             (READ-ONLY)
motiony[] represents the motiony buffer values. Indexing is in [column,row] form.

reflectred[ ]           (READ-ONLY)
reflectred[] represents the reflectred buffer values. Indexing is in [column,row] form.

reflectgreen[ ]       (READ-ONLY)
reflectgreen[] represents the reflectgreen buffer values. Indexing is in [column,row] form.

reflectblue[ ]         (READ-ONLY)
reflectblue[] represents the reflectblue buffer values. Indexing is in [column,row] form.

Methods

The following methods are also available:

copy(left,top, right, bottom)
copy(left, top, right, bottom) creates a new image buffer using the image data contained within the specified area (inclusive) in the current buffer. A buffer identifier is returned for use with the select() method.

paste(bufferid,left, top)
paste(bufferid, left, top) pastes the image data contained in the specified buffer into the currently selected buffer at the given left and top offsets. bufferid must be a value returned by a previous call to the copy() method.

select ([bufferid])
select ([bufferid]) selects an image buffer as the current working buffer. All data members and methods will function upon the selected buffer after this call. Providing no arguments causes the main image buffer to become current.

Example 1:
Using the ImageFilter Object Agent, the process() function of the "Black & White" Image Filter LScript provided with LightWave can be written as follows:

process: ifo
{
    for(i = 1;i <= ifo.height;++i)
    {
         for(j = 1;j <= ifo.width;++j)
         {
              average = (ifo.red[j,i] + ifo.green[j,i] +
ifo.blue[j,i]) / 3;
              ifo.red[j,i] = average;
              ifo.green[j,i] = average;
              ifo.blue[j,i] = average;
         }
    }
}

Example 2:

The following example uses the copy(), paste(), and select() methods to swap the two vertical halves of an image:

process: ifo
    buf1 = ifo.copy(1,1,ifo.width / 2,ifo.height);
    buf2 = ifo.copy(ifo.width / 2,1,ifo.width,ifo.height);
    ifo.select(buf1);
    buf_width = ifo.width;
    ifo.select();
    ifo.paste(buf2,1,1);
    ifo.paste(buf1,buf_width,1);
}

General Commands

overlayglyph();

Image Filter LScripts can use a new function called overlayglyph() to blend a Glyph Object Agent onto the image data cache. This function takes a Glyph Object Agent reference and an X and Y offset position where the Glyph will be stamped onto the image cache. An optional fourth argument allows the Glyph image to be composited onto the image cache with a transparency (alpha) value, ranging from 0.0, which renders the Glyph without transparency (the default value), to 1.0, which renders the Glyph with 100% transparency (the Glyph will not be visible).

bug;

create
{
bug = Glyph(vt4000,true);
setdesc("Bug");
}

process: width, height, frame, starttime, endtime
{
overlayglyph(bug,1,1);
overlayglyph(bug,1,height - bug.h,0.25);
overlayglyph(bug,width - bug.w,height - bug.h,0.5);
overlayglyph(bug,width - bug.w,1,0.75);
overlayglyph(bug,(width - bug.w) / 2,(height - bug.h) / 2,0.25);
}

@data vt4000 67800
000 000 002 000 000 000 000 000 000 000 000 000 188 000 120 000 024 000 026 026
026 025 025 025 025 025 025 025 025 025 026 026 026 026 026 026 025 025 025 025
...
000 000 000 000 000 000 084 082 085 069 086 073 083 073 079 078 045 088 070 073
076 069 046 000
@end

Layout Commands

Backdrop();