<< Chapter < Page
  Digital signal processing - dsp     Page 12 / 24
Chapter >> Page >

A 3D parabolic surface

The array of surface elevation data is populated by the code in Listing 2 .

Listing 2. A 3D parabolic surface,
for(int row = 0;row<numberRows;row++){ for(int col = 0;col<numberCols;col++){ int xSquare = col * col;int ySquare = row * row; data[row][col] = xSquare + ySquare;}//end col loop }//end row loop

I will allow you to evaluate this code on your own. It creates a 3D surface with the lowest elevation at the upper left corner and the highest elevation atthe lower right corner. The surface is a one-quarter section of a 3D parabola, as shown in Figure 3 .

Display six surface images

Listing 3 shows the code that causes the 3D surface elevation data to be displayed as six independent images (each statement in Listing 3 produces one output image) .

IMPORTANT: this is the same code that would be used by other programs to incorporate this 3D surface plottingcapability into those programs.
Listing 3. Display six surface images.
new ImgMod29(data,blockSize,true,0); new ImgMod29(data,blockSize,false,1);new ImgMod29(data,blockSize,true,2); new ImgMod29(data,blockSize,true,3);new ImgMod29(data,blockSize,false,4); new ImgMod29(data,blockSize,true,5);

Just instantiate an object

All that is necessary for another program to incorporate this class to display a 3D surface is to instantiate an object of the class named ImgMod29 passing four parameters to the constructor.

The parameters

The first parameter is a reference to the 2D array of type double containing the surface elevation values.

The second parameter is the blockSize . This int value specifies the size of one side of a square of pixels, (all of the same color) that will be used to represent each surface elevation value in the final display. As mentioned earlier, this value was set to 2 in the sampledisplays produced by the main method. However, it could have been any reasonable value such as 5, 10, or 15 for example.

The third parameter is true if you want the red axes to be drawn and is false otherwise (as shown in Figure 3 ) .

The fourth parameter is an integer value between 0 and 5 inclusive, which specifies the plotting format as follows:

  • 0 - Grayscale (linear)
  • 1 - Color Shift (linear)
  • 2 - Color Contour (linear)
  • 3 - Grayscale with logarithmic data conversion before plotting
  • 4 - Color Shift with logarithmic data conversion before plotting
  • 5 - Color Contour with logarithmic data conversion before plotting

Instantiate six separate objects

Listing 3 instantiates six such objects to display the same 3D surface, one for each plotting format as shown in Figure 3 . Some of the objects display the axes and others do not. All use a blockSize value of 2.

Each display object appears in the upper-left corner of the screen. Thus, when two or more such objects are instantiated, they appear as a stack. It isnecessary to physically move those on top of the stack to see those further down.

Listing 3 signals the end of the main method.

The ImgMod29 class

Listing 4 shows the beginning of the class named ImgMod29 and the beginning of the constructor for the class.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Digital signal processing - dsp. OpenStax CNX. Jan 06, 2016 Download for free at https://legacy.cnx.org/content/col11642/1.38
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Digital signal processing - dsp' conversation and receive update notifications?

Ask