<< 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.
scaleTheSurfaceData();

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
Donatius
compensation of goods and services by a customer with price that willing to satisfy themselves.
Kho
who describe economic
yao Reply
thediminishingarginalutility
Stanley Reply
mean
yao
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
Fatema
I don't understand it I tried to learn from form one but still don't understand
Hawa
jxt follow the notes well try solving question under it
Nana
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
Asive
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.
Ahmad
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.
Ahmad
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.
Basanta
refers to amount of commodities a consumer is willing and able to buy at particular price within a period of time
Clifford
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
kum
It refers to the quality of a commodity purchased in the market at a price and at a point of time .
Cobby
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
Tina
In which case is opportunity cost is zero
Francis Reply
where no alternative is available
Bhartendu
who is the father of economic
Omar Reply
Adam Smith
Suraj
ok
Tony
Adam Smith
Francis
Adam smith
Opana
Adam Smith
Basanta
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?

Ask