Write a function called blackAndWhite that has as input argument the file name of an image file (example: bluefish.gif), then transforms the image in black and white and displays it. In order to create a black and white image, do:

  1. Prepare the image file: (i.e open the image file and convert it into RGB representation)

  2. Display the initial image

  3. Loop over each pixel in the image (hint: you'll need a nested for loop) and compute the average of r, g, b. Next, update the pixel value with average.

  4. Save the new image in a file called: filename”_BW_mod.gif”

  5. Display the black and white image on screen

TrustyTony commented: Not own effort shown, no questions asked -3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.