Question: Write the method lightenImage that modifies the image by changing the values in the instance variable pixels according to the following conditions: The value at
Write the method lightenImage that modifies the image by changing the values in the instance variable pixels according to the following conditions:
The value at position row col is increased by the value at row col if the position is valid.
If the new value is greater than the value WHITE, the pixel is assigned the value WHITE.
If there is no pixel at position row col the value is unchanged.
The following shows the contents of the instance variable pixels before and after a call to lightenImage. The bolded values represent the values that could be modified in the image.
Before lightenImage
After lightenImage
Complete the method lightenImage below.
Increases the value of each pixel at row col
by the value of the pixel at row col if
the position is valid. If the value is greater
than WHITE, the pixel value is set to WHITE.
If there is no pixel at row col the
value is unchanged.
public void lightenImage The method must do the following: Accesses all necessary elements in at least one row or one column of pixels
Accesses all necessary elements of pixels no bounds errors
Increases the value at index rowcol by the value found at index rowcol
Modifies all appropriate elements of pixels
Assigns WHITE or to elements of pixels that would otherwise have a value greater than WHITE
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
