Next: Performance
Up: Interactive Textbooks; Embedding Image
Previous: Thinning
The independent operators described in the previous section can be embedded
and interact in an HTML document for display in a Web page.
This can be achieved by the following piece of HTML code:
<APPLET CODE="AddNoise.class" WIDTH=800 HEIGHT=400>
<PARAM NAME=images VALUE="images/holesquare2.gif">
</APPLET>
which adds the applets to an HTML page.
If the parameter named images is given a value (as in this case)
then it used, otherwise a default image is loaded.
Then, the output image from each applet is linked to the
next one down the page so that it can be further processed.
The way this is achieved is by giving each applet the ability to
communicate with the next one.
The procedure which JAVA employs to grant applets the privilege of
communicating with each-other is fairly simple and works as follows:
- The applet must be given a name using the NAME
parameter in the relevant HTML document e.g.
<APPLET CODE="AddNoise.class" WIDTH=800 HEIGHT=400 NAME="addnoise">
- Then, one must use the getApplet() method from the applet
context with the name of that applet as a parameter. This will
return a reference to that applet. One can use this
applet as if it were an object and manipulate it accordingly. For
example, if one wished to obtain the applet named ``addnoise''
belonging to the AddNoise class one would need to declare an
AddNoise variable and cast the applet obtained by getApplet()
to that class:
AddNoise addnoise_applet;
addnoise_applet = (AddNoise)getAppletContext().getApplet("addnoise");
- All one needs to do now is define the functions that will
implement the communication protocol.
Each applet has been
equipped with two extra functions. One of these functions is
send_image(), which activates when
the ``Forward Results'' button has been pressed, thus
sending the whole integer array of
the final image produced by this applet to the next applet on the page.
For example, consider Figure 9. The
applets pictured are called ``gamma'' and ``addnoise''
respectively. After ``Forward Results'' has been pressed and the
gamma operation repeated, the resulting image is passed on to the
``addnoise'' applet (Figure 9).
This is achieved by a call to send_image() which, in turn,
calls the function set_src_image() of the ``addnoise''
applet in the usual object-oriented way:
addnoise_applet.set_src_image(img_1d);
This function's purpose is to set the source image of the
applet which defines it to be the image sent by the applet that calls it.
Now each applet can pass its image to the next applet.
To make the communication procedure more general, a parameter has been
added which can be set from the relevant HTML document. This
parameter is called receiver_applet and is used to set the
destination of the resulting image of an applet. If this parameter is
missing, the default is to send the image to the next applet in the
manner described above.
Next: Performance
Up: Interactive Textbooks; Embedding Image
Previous: Thinning
Bob Fisher
Fri Jul 4 16:11:50 BST 1997