Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Language= python only use NumPy and Matplotlib Give detail to which code for which box 3. (13 points) Write a function chessBoard(m, n) that takes

Language= python

only use NumPy and Matplotlib

image text in transcribed

Give detail to which code for which box

3. (13 points) Write a function chessBoard(m, n) that takes as input two integers m and n, and returns a 100 x 200 NumPy array that represents an mx n black and white chessboard image. We assume that each pixel in the image is represented by a single real number between 0 and 1, representing the gray scale from black to white. Note: You should only use Numpy and Matplotlib for this problem. To get full credits, you should avoid using any explicit for/while loops. In [ ]: # run this cell to import necessary modules # DO NOT DELETE import matplotlib.pyplot as plt import numpy as np In [ ]: # put your code here Test your function by running the following cell. In [ ]: # Test your code here # DO NOT DELETE img = chessBoard(5,10) plt.imshow(img, cmap = "gray") plt.show() The resulting image should be similar to the following image: In [1]: # Run the cell to show the test image # DO NOT DELETE from IPython.display import Image, display display (Image("chessboard_demo.png")) 0 20 40 60 80 0 25 50 75 100 125 150 175 3. (13 points) Write a function chessBoard(m, n) that takes as input two integers m and n, and returns a 100 x 200 NumPy array that represents an mx n black and white chessboard image. We assume that each pixel in the image is represented by a single real number between 0 and 1, representing the gray scale from black to white. Note: You should only use Numpy and Matplotlib for this problem. To get full credits, you should avoid using any explicit for/while loops. In [ ]: # run this cell to import necessary modules # DO NOT DELETE import matplotlib.pyplot as plt import numpy as np In [ ]: # put your code here Test your function by running the following cell. In [ ]: # Test your code here # DO NOT DELETE img = chessBoard(5,10) plt.imshow(img, cmap = "gray") plt.show() The resulting image should be similar to the following image: In [1]: # Run the cell to show the test image # DO NOT DELETE from IPython.display import Image, display display (Image("chessboard_demo.png")) 0 20 40 60 80 0 25 50 75 100 125 150 175

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

Students also viewed these Databases questions

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago