SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 5 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 12 Oct 2017 My Price 10.00

I wrote few code under the # write your code here for homework and it return invalid syntax.

Pyramid BlendingThis file has a number of functions that you need to fill out in order tocomplete the assignment. Please write the appropriate code, following theinstructions on which functions you may or may not use.References----------See the following papers, available on T-square under references:(1) "The Laplacian Pyramid as a Compact Image Code"Burt and Adelson, 1983(2) "A Multiresolution Spline with Application to Image Mosaics"Burt and Adelson, 1983Notes-----You may not use cv2.pyrUp or cv2.pyrDown anywhere in this assignment.GENERAL RULES:1. DO NOT INCLUDE code that saves, shows, displays, writes the image thatyou are being passed in. Do that on your own if you need to save the imagesbut these functions should NOT save the image to disk.2. DO NOT import any other libraries aside from those that we provide.You should be able to complete the assignment with the given libraries(and in many cases without them).3. DO NOT change the format of this file. You may NOT change functiontype signatures (not even named parameters with defaults). You may addadditional code to this file at your discretion, however it is yourresponsibility to ensure that the autograder accepts your submission.4. This file has only been tested in the course virtual environment.You are responsible for ensuring that your code executes properly in thevirtual machine environment, and that any changes you make outside theareas annotated for student code do not impact your performance on theautograder system."""import numpy as npimport scipy as spimport scipy.signal# one option for a 2D convolution libraryimport cv2def generatingKernel(a):"""Return a 5x5 generating kernel based on an input parameter (i.e., asquare "5-tap" filter.)Parameters----------a : floatThe kernel generating parameter in the range [0, 1] used to generate a5-tap filter kernel.Returns-------output : numpy.ndarrayA 5x5 array containing the generated kernel"""# DO NOT CHANGE THE CODE IN THIS FUNCTIONkernel = np.array([0.25 - a / 2.0, 0.25, a, 0.25, 0.25 - a / 2.0])return np.outer(kernel, kernel)def reduce_layer(image, kernel=generatingKernel(0.4)):"""Convolve the input image with a generating kernel and then reduce itswidth and height each by a factor of two.For grading purposes, it is important that you use a reflected border(i.e., padding equivalent to cv2.BORDER_REFLECT101) and only keep the validregion (i.e., the convolution operation should return an image of the sameshape as the input) for the convolution. Subsampling must include the firstrow and column, skip the second, etc.
Background image of page 1
Example (assuming 3-tap filter and 1-pixel padding; 5-tap is analogous):fefghgabcdPadbabcdcConvolveZYXWSubsampleZXefgh------->fefghg-------->VUTS-------->RPijklBORDERjijklkkeepRQPOJHmnopREFLECTnmnopovalidNMLKqrst5rqrstsJIHGnmnopoA "3-tap" filter means a 3-element kernel; a "5-tap" filter has 5 elements.Please consult the lectures for a more in-depth discussion of how totackle the reduce function.Parameters----------image : numpy.ndarrayA grayscale image of shape (r, c). The array may have any data type(e.g., np.uint8, np.float64, etc.)kernel : numpy.ndarray (Optional)A kernel of shape (N, N). The array may have any data type (e.g.,np.uint8, np.float64, etc.)Returns-------numpy.ndarray(dtype=np.float64)An image of shape (ceil(r/2), ceil(c/2)). For instance, if the input is5x7, the output will be 3x4."""# WRITE YOUR CODE HERE.image = np.float64(image)image = cv2.copyMakeBorder(image,5,5,5,5,cv2,BORDER_REFLECT)kernel = np.float64(kernel)image = scipy.signal.convolve2d(image, kernel, 'same')image = image[5:-5, 5:-5]image = image[::2, ::2]return np.float64(image)raise NotImplementedErrordef expand_layer(image, kernel=generatingKernel(0.4)):"""Upsample the image to double the row and column dimensions, and thenconvolve it with a generating kernel.Upsampling the image means that every other row and every other column willhave a value of zero (which is why we apply the convolution after). Forgrading purposes, it is important that you use a reflected border (i.e.,padding equivalent to cv2.BORDER_REFLECT101) and only keep the valid region(i.e., the convolution operation should return an image of the sameshape as the input) for the convolution.Finally, multiply your output image by a factor of 4 in order to scale itback up. If you do not do this (and you should try it out without that)you will see that your images darken as you apply the convolution.You must explain why this happens in your submission PDF.Example (assuming 3-tap filter and 1-pixel padding; 5-tap is analogous):000000UpsampleA0B0Pad0A0B0BConvolvezyxwAB------->0000------->000000------->vutsCDC0D0BORDER0C0D0DkeeprqpoEF0000REFLECT000000validnmlkE0F00E0F0Fjihg0000000000fedc0E0F00NOTE: Remember to multiply the output by 4.A "3-tap" filter means a 3-element kernel; a "5-tap" filter has 5 elements.Please consult the lectures for a more in-depth discussion of how totackle the expand function.Parameters
Background image of page 2

Answers

(5)
Status NEW Posted 12 Oct 2017 09:10 AM My Price 10.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)