Question: In this lab, we will explore image processing, using some common operations. The basic code file is provided to you, you need to use this
In this lab, we will explore image processing, using some common operations. The basic code file is provided to you, you need to use this to start and fill in the appropriate sections, using a minimal number of lines in the code and viewing an image as a multidimensional matrix and the image provided to you.
Part 1: Converting an image to Black and White and Greyscale In order to convert a color image to Black and White, you need to calculate the average of the RGB values. If the average is closer to 255, the pixel is set to white (255), otherwise to black (0). For conversion to a greyscale image, the pixel values are set to the averages of the RGB values in principle. In order to better represent how we as humans perceive colours, you should use a weighting factor for each of the RGB values. Do some research online to find those weighting values Do some research to determine how the RGB file format stores colour values if you are not familiar with it yet. Using the Python IDLE and the skeleton code provided, add code that converts a color image to a black and white image and (starting fresh) then a greyscale image. You only need to submit the greyscale code file for this part.
Part 2: Blurring an image Blurring an image is achieved in the simplest case by setting each pixels value to the average of the four neighbours around it. Using the Python IDLE and the skeleton code provided, add code that blurs an image. Research some other blurring algorithms online, in particular do some research on Gaussian blurring and how it uses a weighting for the contribution of the different neighbours.
Part 3: Line Detection for Bonus Mark A basic line detection algorithm looks at the difference of neighbouring values. You should convert the image to greyscale first. Using a threshold, you need to compare a pixels value to the neighbour below and to the right. If the difference in both is larger than a threshold (around 0.3 should work well) you have found an edge and you should set that pixels value to 0, otherwise to 255. Submit the code files for the first two parts for the lab and the code for the last part for a bonus mark using the separate dropbox.
Starting point for code:
import matplotlib.pyplot import numpy myImage = matplotlib.pyplot.imread('flower.png') height=myImage.shape[0] width=myImage.shape[1] for x in range(0, height-1): for y in range(0,width-1): INSERT YOUR CODE HERE imgplot = matplotlib.pyplot.imshow(myImage) matplotlib.pyplot.show() Image to use for debugging:

Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
