Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Method name: makeGrey Parameter(s): A Picture object. This is the source image. Return value: A new Picture object. Each pixel in the returned Picture should

Method name: makeGrey Parameter(s): A Picture object. This is the source image. Return value: A new Picture object. Each pixel in the returned Picture should have a color that is the grey scale equivalent of the corresponding pixel (the pixel with the same x and y coordinate) in the source image. In general, a grey scale color has different ways of being calculated - you must calculate it by averaging the red, green, and blue values from the pixel in the source image and then setting each of the red, green, and blue components of the pixel in the new image to this grey intensity. Example: A single pixel image with a color (100, 200, 50) would have a grey intensity of (100+200+50)/3 = 116 and the new image would be a single pixel with color (116, 116, 116).

Here is the code I have so far.

public static Picture makeGrey(Picture obj) {

Picture newPicture = new Picture(obj);

int width = obj.width();

int height = obj.height();

for(int column = 0; column

for(int row=0; row

Color color = obj.get(column,row);

Color gray =

}

}

return newPicture;

}

The next function I haven't started on is:

Method name: makeNegative Parameter(s): A Picture object. This is the source image. Return value: A new Picture object with the colors changed to a photonegative style. Each pixel in the returned Picture should have a color that is a "negative" of the corresponding pixel (the pixel with the same x and y coordinate) in the source image. You must calculate this by taking each red, green, and blue value in the source and setting it to 255 - each value in the returned image. Example: A single pixel image with a color (100, 200, 50) would make a new image with a single pixel with color (155, 55, 205).

Another is:

  1. Method name: safeColor Parameter(s): A single int value representing one of a red, green, or blue value. Return value: An int that is the same as the parameter, except that it is 0 if the original value is less than zero and it is 255 if the original value is greater than 255. Example: If the parameter is 100, then the return value should be 100. If the parameter is 300, then the return value should be 255.

the Last is:

Method name: makeBrighter Parameter(s): A Picture object. This is the source image. Return value: A new Picture object with the color values doubled. Each pixel in the returned Picture should have a color that has each red, green, and blue component twice that of the corresponding pixel (the pixel with the same x and y coordinate) in the source image. Unthinkingly applied, this doubling will yield color values outside the allowed 0-255 range, which crashes the program. Clamp each calculated red, green, and blue value to a safe range by applying the safeColor method written above to the colors you calculate. Example: A single pixel image with a color (100, 200, 50) would make a new image with a single pixel with color (200, 255, 100).

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

Data And Information Quality Dimensions, Principles And Techniques

Authors: Carlo Batini, Monica Scannapieco

1st Edition

3319241060, 9783319241067

Students also viewed these Databases questions