<< Chapter < Page Chapter >> Page >
This module contains review questions and answers keyed to the module titled Java3006: Implementing a space-wise linear color-modification algorithm.

Revised: Sat Apr 02 20:06:54 CDT 2016

This page is included in the following Books:

Table of contents

Preface

This module contains review questions and answers keyed to the module titled Java3006: Implementing a space-wise linear color-modification algorithm .

The questions and the answers are connected by hyperlinks to make it easy for you to navigate from the question to the answer and back again.

Questions

Question 1 .

True or False? The program shown in Listing 1 will transform the image shown in Figure 1 into the image shown in Figure 2 (or to an image that looks very similar to the image shown in Figure 2 ).

Listing 1 . Source code for Java3006r.
/*File Java3006r Copyright 2013 R.G.Baldwin *********************************************************/public class Java3006r{ public static void main(String[]args){ Java3006rRunner obj = new Java3006rRunner();obj.run(); System.out.println(obj.getPicture());}//end main }//end class Java3006r//======================================================// class Java3006rRunner{//Instantiate the Picture object. private Picture pic = new Picture("Java3006r.jpg"); public Java3006rRunner(){//constructorSystem.out.println("Dick Baldwin"); }//end constructor//----------------------------------------------------// //Accessor methodpublic Picture getPicture(){return pic;} //----------------------------------------------------////This method is where the action is. public void run(){pic.addMessage("Dick Baldwin",10,20); //Display a PictureExplorer object.pic.explore(); //Get an array of Pixel objects.Pixel[] pixels = pic.getPixels();//Declare working variables Pixel pixel = null;int green = 0; int blue = 0;int width = pic.getWidth(); double greenScale = 0;double blueScale = 0; //Scale the blue and green color components according// to the algorithm given above. //Do not scale the red component.for(int cnt = 0;cnt<pixels.length;cnt++){ //Get blue and green values for current pixel.pixel = pixels[cnt];green = pixel.getGreen(); blue = pixel.getBlue();//Compute the column number and use it to compute // the scale factor.int col = cnt%width; greenScale = (double)(width - col)/width;blueScale = (double)(col)/width; //Apply the scale factor.pixel.setGreen((int)(green * greenScale)); pixel.setBlue((int)(blue * blueScale));}//end for loop //Display a PictureExplorer object.pic.explore(); }//end run method}//end class Java3006rRunner

Figure 1 - The image from Java3006r.jpg.

This is the input image to the program named Java3006r.

Figure 2 - Possible output image.

This is a color modified version of the input image with the colors ranging from near yellow on the left to near magenta on the right.

Answer 1

Question 2

True or False? The output shown in Figure 2 was produced by calling the show method of Ericson's Picture class.

Answer 2

Question 3

True or False? A call to Ericson's getPixels method returns a reference to a one-dimensional array object. The elements in the array are references to Pixel objects, where each Pixel object represents a single pixel in an image.

Questions & Answers

what is mutation
Janga Reply
what is a cell
Sifune Reply
how is urine form
Sifune
what is antagonism?
mahase Reply
classification of plants, gymnosperm features.
Linsy Reply
what is the features of gymnosperm
Linsy
how many types of solid did we have
Samuel Reply
what is an ionic bond
Samuel
What is Atoms
Daprince Reply
what is fallopian tube
Merolyn
what is bladder
Merolyn
what's bulbourethral gland
Eduek Reply
urine is formed in the nephron of the renal medulla in the kidney. It starts from filtration, then selective reabsorption and finally secretion
onuoha Reply
State the evolution relation and relevance between endoplasmic reticulum and cytoskeleton as it relates to cell.
Jeremiah
what is heart
Konadu Reply
how is urine formed in human
Konadu
how is urine formed in human
Rahma
what is the diference between a cavity and a canal
Pelagie Reply
what is the causative agent of malaria
Diamond
malaria is caused by an insect called mosquito.
Naomi
Malaria is cause by female anopheles mosquito
Isaac
Malaria is caused by plasmodium Female anopheles mosquitoe is d carrier
Olalekan
a canal is more needed in a root but a cavity is a bad effect
Commander
what are pathogens
Don Reply
In biology, a pathogen (Greek: πάθος pathos "suffering", "passion" and -γενής -genēs "producer of") in the oldest and broadest sense, is anything that can produce disease. A pathogen may also be referred to as an infectious agent, or simply a germ. The term pathogen came into use in the 1880s.[1][2
Zainab
A virus
Commander
Definition of respiration
Muhsin Reply
respiration is the process in which we breath in oxygen and breath out carbon dioxide
Achor
how are lungs work
Commander
where does digestion begins
Achiri Reply
in the mouth
EZEKIEL
what are the functions of follicle stimulating harmones?
Rashima Reply
stimulates the follicle to release the mature ovum into the oviduct
Davonte
what are the functions of Endocrine and pituitary gland
Chinaza
endocrine secrete hormone and regulate body process
Achor
while pituitary gland is an example of endocrine system and it's found in the Brain
Achor
what's biology?
Egbodo Reply
Biology is the study of living organisms, divided into many specialized field that cover their morphology, physiology,anatomy, behaviour,origin and distribution.
Lisah
biology is the study of life.
Alfreda
Biology is the study of how living organisms live and survive in a specific environment
Sifune
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Object-oriented programming (oop) with java. OpenStax CNX. Jun 29, 2016 Download for free at https://legacy.cnx.org/content/col11441/1.201
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Object-oriented programming (oop) with java' conversation and receive update notifications?

Ask