Answered step by step
Verified Expert Solution
Question
1 Approved Answer
# import necessary packages # reading / writing image files from skimage import io from skimage import color # array operations import numpy as np
# import necessary packages
# readingwriting image files
from skimage import io
from skimage import color
# array operations
import numpy as np
# displaying images and plots
import matplotlib as mpl
import matplotlib.pyplot as plt
# mathematical calculations
import math
# signal processing operations
from scipy import signal
# random number generation
from scipy.stats import norm
# DFT calculations
from scipy import fftpack as ft
# STEP Estimate the power spectrum of the observed blurred and noisy image
# ADD YOUR CODE HERE
# for every x block of the observed image:
# window the block with a Hanning window use a taper length of
# mywinHanningnSize nTaper:
# take the DFT of each block
# calculate the magnitudesquared of DFTs
# obtain Pgkl as the average over the blocks there should be blocks
def mywinHanningnSize nTaper:
assert nTaper
assert nSize nTaper
# create an array to hold the window
winHann nponesnSize
# taper left and right sides
val math.pi nTaper
for n in rangenTaper:
# calculate taper
w math.cosn val
# assign right taper
winHannnSize nTaper n w
# assign left taper
winHannnTaper n w
return winHann
height, width imgBlurredNoisy.shape
blocksize
taperlength
powerspectrumtotal
numblocks
for i in range height, blocksize:
for j in range width, blocksize:
imgblock imgBlurredNoisyi:iblocksize, j:jblocksize
window mywinHanningblocksize, taperlength
windowedblock imgblock window
fftblock ftfftwindowedblock
powerspectrum npabsfftblock
powerspectrumtotal powerspectrum
numblocks
Pg powerspectrumtotal numblocks The image is x I get x where I should get x matrix. Could you explain why and fix the code? Thank you.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started