Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Okay, now it's your turn to work with an RGB image! Write a program that takes a coloured image and turns it into a greyscale
Okay, now it's your turn to work with an RGB image!
Write a program that takes a coloured image and turns it into a greyscale image according to the method described below.
The program should ask the user to enter a filename, open this file, perform the transformation, and then save the greyscale version of the image to the file 'output.png
To turn a colour image into a greyscale image, we need to decide on a single colour value for each greyscale pixel based on the three colour values from the corresponding RGB pixel For this problem, we will determine the colour value by simply averaging the red, green, and blue colour values and rounding the result down to an integer
Here is an example of the effect your program should produce:
RGB astronaut
astronaut.png
Enter a filename: astronaut.png
Average greyscaled astronaut
output.png
Average colours
The method of averaging RGB colour values to produce a greyscale colour value is flawed. When humans see, our vision isn't influenced by red, green, and blue light equally.
More sophisticated methods perform a weighted average instead, in an attempt to produce an image that looks more close to the original but without colour See this Wikipedia page, for more information.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started