<< Chapter < Page | Chapter >> Page > |
Figure 3 . Program output in self-test mode. |
---|
(Remember, all six output images are displayed on top of one another in the upper-left corner of the screen. You must manually move them tosee all six images.)
The main method creates and displays a surface consisting of a 3D parabola. You can think of the surface as representing a one-quartersection of a bowl, or perhaps a satellite dish with the center of the dish in the upper left corner of the image. The top three images in Figure 3 are the images produced from the raw surface. The bottom three images are the imagesproduced by the log of the surface, (which is no longer a 3D parabola) .
The calibration scale is displayed immediately below the image of each surface.
When the program is executed, the six surfaces are stacked in the upper left corner of the screen. (You must physically move the images on the top to see the images on the bottom.) The stacking order of the surfaces from bottomto top is based on the values of the display parameter in the order 0, 1, 2, 3, 4, 5.
Some of the surfaces show axes and some do not. This is controlled by the value of the constructor parameter named axis . A true value for axis causes the axes to be drawn.
The constructor defines an anonymous inner class WindowListener on the close button on the Frame (the X in the upper right hand corner of the Frame ) . Clicking the close button will terminate the program that uses an object of this class.
The program was tested using J2SE 8.0 and Win 7. Because the program uses Java features that were introduced in J2SE 5.0, it may not compile successfullywith earlier versions of Java.
The program named ImgMod29 is rather long, so as usual I will break it down and discuss it in fragments. You can view a complete listing of theprogram in Listing 29 near the end of the module.
The program consists of a top-level class named ImgMod29 , plus several inner classes. The class includes a main method that is use for self-testing the class. To put things in context, I will beginmy discussion with the main method.
The main method begins in Listing 1 .
Listing 1. Beginning of the main method. |
---|
public static void main(String[] args){int numberRows = 59;
int numberCols = 59;double[][]data =
new double[numberRows][numberCols];int blockSize = 2; |
Listing 1 declares a 2D array of type double to contain the 3D surface elevation data values. This is a square array consisting of 59elevation values on each side. (However, there is no requirement for the surface to be square.)
Listing 1 also defines a value of 2 for the blockSize parameter. This variable will be passed to the constructor for the ImgMod29 class, causing each elevation value to be plotted as a small square of four pixels, two pixels on each side of the square.
(The overall size of the display can be controlled by controlling the size of the array containing the surface elevation values and alsocontrolling the value of blockSize .)
Notification Switch
Would you like to follow the 'Digital signal processing - dsp' conversation and receive update notifications?