Question: Write the method countBlackPixels that returns the number of pixels in the image that contain the value BLACK. For example, if pixels contains the following
Write the method countBlackPixels that returns the number of pixels in the image that contain the value BLACK. For example, if pixels contains the following image:
The call to countBlackPixels would return because there are pixels that have the value BLACK.
Complete the method countBlackPixels below.
Returns the total number of black pixels in the image.
public int countBlackPixels The method must do the following: Accesses all entries in pixels no bounds errors
Compares an element in the array with BLACK or with during traversal
Initializes and increments a counter
Returns the correct count of the number of black pixels in pixels
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
