Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

HELP PYTHON 3.0! a4q2-starter.py: ############# DO NOT MODIFY THIS CODE ############################### import numpy as np import skimage.data as skdata import skimage.util as util import matplotlib.pyplot

HELP PYTHON 3.0! a4q2-starter.py: ############# DO NOT MODIFY THIS CODE ############################### import numpy as np import skimage.data as skdata import skimage.util as util import matplotlib.pyplot as plt plt.gray() # use gray colourmap for displaying grayscale images. plt.title('Yes, this figure window is blank -- just ignore it.') # Load original images (this code would be given) # These are *colour* images (See Problem Solving 2). astro = util.img_as_float(skdata.astronaut()) hubble = util.img_as_float(skdata.hubble_deep_field()) # These are *grayscale* images (See Lecture 13, Demo 2). coins = util.img_as_float(skdata.coins()) cameraman = util.img_as_float(skdata.camera()) ##################################################################### # Start your program here. ############# DO NOT MODIFY THIS CODE ############################### plt.show() ##################################################################### 

image text in transcribed

image text in transcribed

Introduction Let's have some fun with images Have a look in a In the given code, we have retrieved a few images that are built into the skimage.data module. We have prepared two colour images for you, and given them variable names astro and hubble, and two grayscale images which we have named coins and cameraman. They look like this: hubble astro Coins cameraman In the steps below, you will write some code to do some interesting things with these images. You will just be writing a few ines of code. There is no need to make any functions for this question. Remember: grayscale images are just 2D arrays of gray values. In this assignment the arrays have been set up so that all grayscale image array values are between 0.0 and 1.0, with 0.0 being black and 1.0 being white. See Lecture 13 demo 2 for additional background on how grayscale images are represented using arrays Remember: Colour images are 3D arrays. The colour image array variables astro and hubble have been set up so that the values are between 0.0 (no red/green/blue) and 1.0 (maximum red/green/blue) Your Tasks (a) We can darken a colour image by reducing all of the pixel values in all of each of red, green, and blue channels by the same percentage. Darken the astro image by creating a new array where each data item in the new array is half the value of the corresponding value in the original array. Do this without using loops it should be one line of code. Display the result by calling plt.figure0 to make a new figure window, and then call show() with your new array as the argument. The darkened image should like this (but in a figure window): When you have this working, label your code for this task with a comment part (a) and go on to the next part. b) We can blend two images together by taking the average of the corresponding colour values for each pixel. Blend the astro and hubble images by adding them together and dividing the result by 2. Ag you must to do this without using loops, it ain can be done with a single ne of code. However, since the astro image has a height and width of 512 pixels, and the hubble image is larger, you will have to obtain a 512x512x3 slice of the hubble image in order to blend it with the astro image You can use any slice of the hubble image you want, as long as it is the right size. Display the result in a new figure (plt figure using plt.imshow(). When you've done the blending correctly, you should get a result that looks something like this

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

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions

Question

2 The role of economic theory in economics.

Answered: 1 week ago