Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem Description In many Digital Signal Processing applications, the input si

ID: 3754671 • Letter: P

Question

Problem Description In many Digital Signal Processing applications, the input signal consists of a sequence of integer values representing samples of the original signal intensities taken at regular time intervals. Because the signal is usually corrupted with noise, the first processing applied to the input signal is noise removal. The simplest way to perform this task is by smoothing the samples using averaging technique (See Figure 1) Input [100 100 160 100 160 160 160 220 220 220]-> smoothed-[100 120 120 140 140 160 180 200 220 220] smoothed 1]-(input[o]+input1]+input[2])/3-(100 100 160V3-120 smoothed 31- (input[2]+input[3] input[4])/3-160 100 160V3- 140. smoothed 6-(input[S]+input[6 input[71)/3-160 160 160V3-160. Figure.1: Example on smoothing a signal using an averaging filter of three values (the value and its two neighbours). Note that the first and last samples cannot be smoothed since they do not have left or right neighbour. Your task is to design and implement a Python program that first generates a signal (e.g sin(x) for x in the range -180, +180 and saves it in a file called signal.txt. The program will then read the original signal from the file, add noise to it, apply smoothing to the noisy signal and display on the screen the three signals (original, noisy and smoothed) in three different graphs. You should submit two files: A world file (HW1 Xxxxx.docx, where XXXXX represents your ID number) containing your implementation of the development process. In other words, you should provide the following information I. a. Problem Definition: Define the problem in a concise and clear statement of your own words. b. Requirement Specification: Determine input/output data, and their sources/target as well as any constraint that should be considered c. Design: Using a modular approach, provide a structured chart as well as pseudo-codes describing the algorithms of four functions used in your solution (main), readSignal(), addNois(), smoothSignal()). Testing: Submit your test plan together with its implementation. d. Python program (HW1_XXXXX.py, where XXXXX represents your ID number) that performs the following tasks: Generates, the original signal and saves it in signal.txt, reads the signal samples the file and stores them into a table called inputSignal. Where inputSignal[iIO] represents the x values of the signal (eg. Il A 1.

Explanation / Answer

import random,math

def generateSignal():

f=open("signal.txt","w")

for i in range(-180,180):

x = random.randint(-180,180)

y = math.sin(x)

f.write(str(x)+" "+str(y)+' ')

f.close()

def readSignal():

inputSignal = []

f = open("signal.txt","r")

line = f.readline()

while(line):

x,y = map(float,line.strip().split(" "))

inputSignal.append([x,y])

line = f.readline()

f.close()

return inputSignal

def addNoise(inputSignal):

l = len(inputSignal)

noisySignal = inputSignal.copy()

for i in range(l):

noise = (2*random.randint(1,10)-1)*0.1*inputSignal[i][1]

noisySignal[i][1] +=noise

return noisySignal

def smoothSignal(noisySignal,averageFilter):

l = len(noisySignal)

smootedSignal = noisySignal.copy()

for i in range(1,l-averageFilter):

sum1 = 0

for j in range(i,i+averageFilter):

sum1+= noisySignal[j][1]

smootedSignal[i][1] = sum1/averageFilter

return smootedSignal

generateSignal()

averageFilter = int(input("Enter Average Filter: "))

inputSignal = readSignal()

length = len(inputSignal)

if(length<averageFilter):

print("Average Filter is > Length of inputSignal table")

else:

noisySignal = addNoise(inputSignal)

print(inputSignal==noisySignal)

smootedSignal = smoothSignal(noisySignal,averageFilter)

print("smooted signals")

for i in range(length):

print(smootedSignal[i][0]," ",smootedSignal[i][1])

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote