See Question.pdf

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import numpy as np#Load NumPy library for easier numerical computations
from PIL import Image
from PIL import ImageDraw
import random
import pdb

def normalize(input_im):
    base = input_im.min()
    roof = input_im.max()
    diff = roof - base
    scale = diff/255

    input_im = input_im - base
    output = input_im/scale

    return output

# Load image with PIL, convert to grayscale and convert to numpy array
def np_from_img(fname):
    im =
    return np.asarray(im.convert('L'), dtype=np.int32)

# save numpy array as PIL and then save image as file
def save_as_img(ar, fname):

#Normalize the numpy array to 8 bit image consistency
def norm(ar):
    return 255.*np.absolute(ar)/np.max(ar)

#Rotate kernel for convolution by 180 degree.(else its correlation)
def conv_transform(kernel):

    kernel_cp = np.copy(kernel)
    if kernel.ndim == 1:
       nCol = kernel.shape[0]
       for i in range(nCol):
            kernel_cp[i] = kernel[kernel.shape[0]-i-1]
       nRow = kernel.shape[0]
       nCol = kernel.shape[1]
       for i in range(nRow):
            for j in range(nCol):
                kernel_cp[i][j] = kernel[kernel.shape[0]-i-1][kernel.shape[1]-j-1]

    return kernel_cp...
$38.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Python Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats