Question: Starting Code: def red_part_of_an_image(image): red_image = image.clone() # copy the image # go across the image with the for x loop and then move down

Starting Code: 
def red_part_of_an_image(image): red_image = image.clone() # copy the image # go across the image with the for x loop and then move down a row for y in range(0,image.getHeight()): for x in range(0,image.getWidth()): color = image.getPixel(x,y) # get the pixel color red_color = color[0] # pull out the red component new_color = [red_color, 0, 0] # Zero out the green and blue red_image.setPixel(x,y, new_color) # Set the pixel to the new color return red_image # return the finished new image
Make a function that sets every pixel of a new image to the average # of the red, green, and blue parts of the pixel at the same location in the # original. The average is summing them up and dividing by 3. This is one way # to convert a color image to a grey (black-and-white) image. # // means integer division, which produces an int for a result, like 5 // 2 is 2. # Look at the above function for the basic structure you should follow.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!