Question: File 4 : [ histogram.py ] Visualize the ascent image's color distribution using a histogram. In the textbook,you learned to use histogram to show data

File 4: [
histogram.py]
Visualize the ascent image's color distribution using a histogram. In the textbook,you learned to use histogram to
show data distribution. For this task, please follow the steps below:
Step 1: Convert the 2D image array to a 1D array and assign it to a new variable, (use the .flatten() method of
NumPy array, see textbook for details).
The shape of the resulting array should be:
>>flatimg.shape
cdots,(262144,)
It is a 1 D array with 262,144(512*512) elements.
Step 2: Send the 1D array to the plt.hist() method to display the histogram of color distribution. In the method
call, set the number of bins to 256. The resulting histogram will be like this:
File 4 : [ histogram.py ] Visualize the ascent

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!