Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me with the questions below and explain the lines of code. Method 1 : negative Add a method (negative) to Picture.java that takes

Please help me with the questions below and explain the lines of code.

Method 1: negative

Add a method (negative) to Picture.java that takes in two parameters (1 pt), the first and last index which represent the region (part) of the pixel array to be modified.

o The method should access the pixel array of the calling picture object (that is use the this.getPixels() line to store the picture's pixels in an array).

o Then, using a while loop, invert the color (create the negative) of each pixel from the starting index to the ending index (inclusive) (1 pt).

o The method header for this should be something like: public void negative(int start, int end)

Method 2: grayscale

Add another method (named grayscale) to Picture.java. Like the negative method, grayscale should take both a starting and ending index to determine which pixels will be modified (1 pt). For the pixels in the specified range, you need to change the colors to their appropriate grayscale color using another while loop (1 pt).

The method header should look like: public void grayscale(int start, int end)

Method 3: myFilter

Add another method (named myFilter) to Picture.java. Again, this method should take at least two parameters: the first and last index in the pixel array to be modified (1 pt). You may have more parameters, depending on the effect you are using.

Apply any effect of your choice to the pixels in range using a while loop (1 pt). You can use any effect you want other than negative, grayscale, or something shown in the textbook. Take this as a chance to be creative and come up with an interesting effect.

Testing negative, grayscale, and myFilter:

Download the PSA3B.java file and save it in your PSA3/bookClasses directory.

This file will load a Picture of your choice using FileChooser.pickAFile().

Again, you can either choose a file in mediaSources or a personal image.

Display the original image.

Then call the negative method on the top third of pixels in the image. Next call

the grayscale method on the middle third of pixels in the image. Then apply the myFilter method to the bottom third of the pixels in the image (2 pts).

o Hint: Dont hard-code the parameter values for start and end when you call the methods let Java do the calculations for you!

Lastly, display your new image (1 pt).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Guide To Client Server Databases

Authors: Joe Salemi

2nd Edition

1562763105, 978-1562763107

More Books

Students also viewed these Databases questions

Question

Define capital structure.

Answered: 1 week ago

Question

List out some inventory management techniques.

Answered: 1 week ago

Question

Understand why customers are loyal to a particular service firm.

Answered: 1 week ago