Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q 1 : Update the data type of img to float 6 4 and call it Q 1 . Q 2 : Multiply each element

Q1:Update the data type ofimgtofloat64and call itQ1.
Q2:Multiply each element in theQ1array by 10 and call this new arrayQ2.
Q3:
Create a NumPy array calledarrof the following five values: 32,54,67,88,4
Use the NumPy's sum method to add all the values together and store as a variable calledtotal. Do not hard code the answer by manually adding the numbers in your head. Use NumPy functions or you may be counted off during a review of the assignment.
Add this total to every element of theQ2array and call this new arrayQ3.
Q4:Add the `Q3` array to itself (example: array + array) and call it `Q4`. This will add the corresponding values in each cell to each other.
Q5:Subtract 1 from the first item in theQ4array,2 from the 2nd item, 3 from the 3rd item...n from the nthitem and call the new arrayQ5. You shouldnotdo this using any type of loop as that wouldn't be efficient. Hint: Think about creating a second array that could be used in combination with the first array to complete the task.
Q6:Copy theQ5array and call the new arrayQ6(this step makes sure that we are working with a copy instead of a view of the previous array). Update the 4th element in theQ6array to46225.Careful: Remember that Python is zero based index.
Q7:Copy theQ6array and call the new arrayQ7. Select the indices from1,000to200,000(including the element in the200,000index) and the indices from400,000to600,000(including the element in the600,000index) inQ7and add255to only those values.
Hint:Remember that you can do this in two steps:
Step 1) Update the first set of indices
Step 2) Update the second set of indices.
Also remember that Python is zero based index.
As an example, if I wanted to add10to the values in the indices from100to110(including the element in the110index) I could write my code as follows:
Q8:Copy theQ7array and call the new arrayQ8. Reshape theQ8array to a two-dimensional, two-column array.
Q9:Copy theQ8array and call the new arrayQ9. Swap the two columns from thisQ9array. In other words, the first column will now be the second and the second column will now be the first.
Q10:Copy theQ9array and call the new arrayQ10. Reverse the order of the rows of theQ10array.
Q11:Copy theQ10array and call itQ11. SetQ11's 101st row as[46225,353].Careful: Remember that Python is zero based index
Q12:Copy theQ11array and call itQ12. Set thefirst elementinQ12's100,001st row to46656. The second element in that row should remain unchanged.Careful: Remember that Python is zero based index
Q13:Copy theQ12array and call itQ13. Subtract 125 from every element in thesecond columnforQ13.
Q14:Copy theQ13array and call itQ14. Take the square root of every element in thefirst columnofQ14.
Q15:Copy theQ14array and call itQ15. Change any value in theQ15array that is currently 999 and set it to 117.
Q16:
Copy theQ15array and call itQ16.
Take the transpose of theQ16array.
Subtract 125 from the first column of all rows.
Take the transpose of the array again (this puts it back in its original state) making sure that all the changes are saved asQ16.
Q17:Copy theQ16array and call itQ17. Reshape theQ17array to (423,640,3). Note: the 3 values in each row are the RGB values for every pixel of the picture.
Q18: Copy the `Q17` array and call it `Q18`. Cast the entire `Q18` array as an `int`.
Q19:Run the code below to plot your array below.
Q20:Create a variable calledQ20that is a string of the phrase in the picture (include punctuation but not the name of the author). You can of course hard code this string.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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