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

New to j2se 5.0

According to Oracle's documentation, the log10 method became part of Java with the release of J2SE 5.0. Therefore, this code is notcompatible with earlier versions of Java.

Here are a couple of restrictions taken from Oracle's documentation that apply to the use of the method named log10 :

  • If the argument is NaN or less than zero, then the result is NaN.
  • If the argument is positive zero or negative zero, then the result is negative infinity.

Because of the first restriction, the code in Listing 7 converts all negative values into positive values before performing the conversion. Because of thesecond restriction, no attempt is made to compute the log of elevation values of zero.

Otherwise, the code in Listing 7 is straightforward and should not require further explanation.

Normalize the surface elevation data

After converting the elevation data to log form, (or not converting as the case may be) , the code in Listing 8 calls the method named scaleTheSurfaceData to normalize the elevation data by squeezing it into the integer range between 0and 255 inclusive. When this method returns, the lowest elevation has a value of 0 and the highest elevation has a value of 255.

Listing 8. Normalize the surface elevation data.

The elevation data is normalized to this range to make it easier later to form relationships between the elevation values and allowable color values.

(Recall that allowable color values range from 0 to 255.)

The method named scaleTheSurfaceData

At this point, we will take a side trip and examine the method named scaleTheSurfaceData , which is shown in its entirety in Listing 9 .

Listing 9. The method named scaleTheSurfaceData.
double min; double max;//This method is used to scale the surface data // to force it to fit in the range from 0 to// 255. void scaleTheSurfaceData(){//Find the minimum surface value. min = Double.MAX_VALUE;for(int row = 0;row<dataHeight;row++){ for(int col = 0;col<dataWidth;col++){ if(data[row][col]<min) min = data[row][col];}//end col loop }//end row loop//Shift all values up or down to force new // minimum value to be 0.for(int row = 0;row<dataHeight;row++){ for(int col = 0;col<dataWidth;col++){ data[row][col] = data[row][col] - min;}//end col loop }//end row loop//Now get the maximum value of the shifted// surface values max = -Double.MAX_VALUE;for(int row = 0;row<dataHeight;row++){ for(int col = 0;col<dataWidth;col++){ if(data[row][col]>max) max = data[row][col];}//end col loop }//end row loop//Now scale all values to cause the new // maximum value to be 255.for(int row = 0;row<dataHeight;row++){ for(int col = 0;col<dataWidth;col++){ data[row][col] =data[row][col]* 255/max; }//end col loop}//end row loop }//end scaleTheSurfaceData

While this method is rather long, it is completely straightforward and shouldn't require further explanation.

Create an appropriate pair of Canvas objects

Return now to the discussion of the constructor for the ImgMod29 class.

Questions & Answers

pls who is a consumer
Cobby Reply
whoever use the product can be the consumer either the buyer of it or people at home who will be using the product
compensation of goods and services by a customer with price that willing to satisfy themselves.
who describe economic
yao Reply
Stanley Reply
pls I'm a home economic student and went I was in my formal school I was doing biology so wen I got she 2 and I went a different school and that school they don't do biology what they do is economics and I don't understand it cos I didn't learn from form one so I will need ur help in this please
Hawa Reply
what help u need
I don't understand it I tried to learn from form one but still don't understand
jxt follow the notes well try solving question under it
important of economics
Benita Reply
what is supply chain
Jos Reply
what is financial management? And why is it necessary in business ?
Fatema Reply
it is the managing of all transactions that take place in any business and if not managed properly it could create debts and destroy the business
What is demand?
Annonymous Reply
why is degree important in economics
Ebunoluwa Reply
important of enocomic
Adu Reply
what is division of labour
Dennis Reply
division of labour can be defined as the separation of task to individuals in any economic system to specialize on it.
what is demand curve
Victoria Reply
demand curve is a downward sloping economic graph that shows the relationship between the price of product and the quantity of the product demanded.
What is demand
Frank Reply
It refers to the quantity of a commodity purchased in the market at a price and at a point of time.
refers to amount of commodities a consumer is willing and able to buy at particular price within a period of time
It is the ability and willingness a customer buys a product or service at a particular price, place and time while other things remaining constant or the same
It refers to the quality of a commodity purchased in the market at a price and at a point of time .
demand refers to the quantity of goods and services a consumer is willing and able to buy at a given price within a a specific period of time
In which case is opportunity cost is zero
Francis Reply
where no alternative is available
who is the father of economic
Omar Reply
Adam Smith
Adam Smith
Adam smith
Adam Smith
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!

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?