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

MATLAB Functions (60 pts) Below are 5 distinct functions for you to write in Mat

ID: 2248226 • Letter: M

Question

MATLAB Functions (60 pts) Below are 5 distinct functions for you to write in Matlab. These functions are designed to demonstrate different components of image quality and signal processing. addNoise (12 pts.) The Function should be able to: 1) Read in an arbitrary grayscale image given by the file path 2) Calculate the signal to noise ratio of the image using any method from the book 3) Add Gaussian noise to the image for user specified mean and standard deviation 4) Recalculate the signal to noise ratio of the image with noise added 5) Return the image with added noise as well as the noise function that was generated. 6) Return the signal to noise ratio of the image both before and after noise has been added

Explanation / Answer

1)

Syntax

A = imread(filename)

A = imread(filename,fmt)

A = imread(___,idx)

A = imread(___,Name,Value)

[A,map] = imread(___)

[A,map,transparency] = imread(___)

imread returns a , A.

Display the image.

Read an image and convert it to an RGB image.

Read the first image in the sample indexed image file, corn.tif.

X is a 415-by-312 array of type uint8.

Verify that the colormap, map, is not empty, and convert the data in X to RGB.

View the size and class of X.

2)Signal to noise ratio

Syntax

r = snr(x,y)

r = snr(x)

r = snr(x,fs,n)

r = snr(pxx,f,'psd')

r = snr(pxx,f,n,'psd')

r = snr(sxx,f,rbw,'power')

r = snr(sxx,f,rbw,n,'power')

r = snr(___,'aliased')

[r,noisepow] = snr(___)

snr(___)

The common definition of SNR is the power of the wanted signal divided by the noise power. Suppose you have obtained the wanted and the noise signal as arrays, calculation of the SNR in Matlab before noise reduction can be done like this:

After noise reduction, the residual noise can be calculated as the difference of the wanted signal and the actual signal. Calculation of SNR is then straightforward:

=======================================================

3)example: Compute the signal-to-noise ratio (SNR) of a 20 ms rectangular pulse sampled for 2 s at 10 kHz in the presence of Gaussian noise. Set the random number generator to the default settings for reproducible results.

4)

Compute and compare the signal-to-noise ratio (SNR), the total harmonic distortion (THD), and the signal to noise and distortion ratio (SINAD) of a signal.

Create a sinusoidal signal sampled at 48 kHz. The signal has a fundamental of frequency 1 kHz and unit amplitude. It additionally contains a 2 kHz harmonic with half the amplitude and additive noise with variance 0.1².

Verify that SNR, THD, and SINAD agree with their definitions.

5)have a function awgn that adds (white Gaussian) noise to attain a desired signal-to-noise power level; the following is the relevant portion of the code (from the Octave function):

6)

A signal x takes values from an alphabet set. As an example let the alphabet set be {±1} {±1} . A noise of signal to noise ratio of 0 db is added in the following way: