Home / Expert Answers / Computer Science / logout-help-not-trusted-4-python-3-ipykernel-o-run-code-arrays-grids-and-plotting-10-mar-pa483

(Solved): + Logout Help Not Trusted 4 Python 3 (ipykernel) O Run Code Arrays, Grids and Plotting (10 mar ...



+
Logout
Help
Not Trusted
? 4
Python 3 (ipykernel) O
Run
Code
Arrays, Grids and Plotting (10 marks)
Question 2a (4 marks)
Sta

+ Logout Help Not Trusted ? 4 Python 3 (ipykernel) O Run Code Arrays, Grids and Plotting (10 marks) Question 2a (4 marks) Starting with the code and data below, modify and extend it to: Modify the code to: 1. Plot the given image four times as a 2x2 set of subplots (1 mark) 2. Complete the function which takes an image and creates a new image with the colours from two of the colour channels switched. e.g. create a new image with the red (0) channel switched with the green (1) channel. Your function should check that the channel values are valid. If not, the original image should be returned. (2 marks) 3. Update the subplots to show the original, plus the three switched image possibilities. Give each subplot an appropriate title, and the overall plot a super title (1 mark) In [27]; import matplotlib.pyplot as plt import matplotlib.image as im import numpy as np def channel Swapper (img, ch?, ch2): # complete this function plt.rcParams ['figure.figsize'] = [12, 12] leafl = im. imread("images/leafl.jpg") print "Leaf shape: ", leafl.shape) plt.title('2x2 set of subplots') plt.imshow (leafl) plt.show() call last) A


We have an Answer from Expert

View Expert Answer

Expert Answer


Hi, Here is the required code: import matplotlib.pyplot as plt import matplotlib.image as im import numpy as np def channelSwapper(img, ch1, ch2): new_img = img.copy() temp = new_img[:, :, ch1] new_img[:
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe