Question: PLEASE HELP ME WITH THIS WHOLE PYTHON PROGRAMMING PROJECT Activity 1: Read the Image file In this activity, you need to execute a code cell
PLEASE HELP ME WITH THIS WHOLE PYTHON PROGRAMMING PROJECT
Activity 1: Read the Image file
In this activity, you need to execute a code cell which will read the image file from the link given using the imread() function.
The basic syntax for the imread() function in the matplotlib.pyplot module is:
Syntax: matplotlib.pyplot.imread(path)
Where,
path: address path of the image to be read.
The output of the imread() function is an array of shape (height, width, dimension).
Note: The dimension is based on the type of image. In this case the dimension will be 3 as we already know image includes 8 bits each of R, G and B.
The steps to be followed are:
1. Execute the below code section to read the image.
[ ]
# Run this code cell to read the image file import matplotlib.pyplot as plt img = plt.imread('https://s3-whjr-v2-prod-bucket.whjr.online/71d278a3-604d-4f24-a6a4-4e09f0ae11ca.png') print(img) As it can be observed, a sequence gets created for storing the pixel values of the image.
2. Verify the type of the output variable and it's shape.
[ ]
# Print the type and shape of the image variable created.
Q: Looking at the shape of the output, what is the height and width of the image?
A:
After this activity, the image file should be converted into an array of pixels.
Activity 2: Display the Image
In this activity, you have to display the image using the matplotlib.pyplot.imshow() function using different parameters.
1. Display the image using the default parameters set for the imshow() function.
[ ]
# Display the image using the default parameters
2. Display the image by adding the cmap ="gray" to try and display the image in grayscale.
[ ]
# Display the image using the cmap parameter
Q Is there any change in the image display?
A
3. Display the image in 2D format. For that, pass img[:,:,0] parameter inside imshow() function:
[ ]
# Display the image using the cmap parameter
Q Is there any change in the image display?
A
4. Display the image with two dimension and the cmap ="gray" to try and display the image in grayscale.
[ ]
# Display the image in two dimension and cmap='gray' parameter.
Q: Is the image displayed in grayscale?
A:
After this activity, the image file should be displayed in 2D format as well as in grayscale.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
