Reference no: EM132345169
1st program -Character encoding using ASCII values rotation w.r.t to certain range
2nd program - Image blur problem
3rd program - Echo generation in audio file
In every text file, Mentioned errors for certain inputs-Please make the program to work for such inputs.
If required, please change the program,
Requirement is given as questions in the file.
Echo Generator
Write a function called echo_gen that adds an echo effect to an audio recording. The function is to be called like this:
output = echo_gen(input, fs, delay, amp);
where input is a column vector with values between -1 and 1 representing a time series of digitized sound data. The input argument fs is the sampling rate. The sampling rate specifies how many samples we have in the data each second. For example, an audio CD uses 44,100 samples per second. The input argument delay represent the delay of the echo in seconds. That is, the echo should start after delay seconds have passed from the start of the audio signal. Finally, amp specifies the amplification of the echo which normally should be a value less than 1, since the echo is typically not as loud as the original signal.
The output of the function is a column vector containing the original sound with the echo superimposed. The output vector will be longer than the input vector if the delay is not zero (round to the nearest number of points needed to get the delay, as opposed to floor or ceil). A sound recording has values between -1 and 1, so if the echo causes some values to be outside of this range, you will need to normalize the entire vector, so that all values adhere to this requirement.
MATLAB has several sample audio files included that you can try: splat, gong, and handel are a few examples. Try the following:
load gong % loads two variables, y and Fs
sound(y, Fs) % Outputs sound
To hear the sound you will need to use desktop MATLAB or MATLAB Online.
(Note that we are assuming mono audiofiles. You can load your own audio files using the audioread function in MATLAB. If the audio data has two columns, it is a stereo file, so use only one column of the data when testing your file.)
errors
%Variable output has an incorrect value.
%Tested with the vector [-0.5; 0; 0.5; 0] and the following parameters: fs = 1, delay: 0.0 seconds, amp = 0.5
% Assessment result: incorrectUsing splat sound file
%Variable output has an incorrect value.
%Tested with the splat file and the following parameters: fs = 8192, delay: 0.2 seconds, amp = 0.2
Image blur
Write a function called blur that blurs the input image. The function is to be called like this:
output = blur(img,w);
where img, the input image is a two-dimensional matrix of grayscale pixel values between 0 and 255. Blurring is to be carried out by averaging the pixel values in the vicinity of every pixel. Specifically, the output pixel value is the mean of the pixels in a square submatrix of size 2w+1 where the given pixel sits in the center. For example, if w is 1, then we use a 3x3 matrix, that is, we average all the neighboring pixels of the given pixel and itself. Only use valid pixels when portions of the blurring matrix fall outside the image. For example, the blurred value corresponding to w = 1 at index (1,1) would be the mean of of elements (1,1), (1, 2), (2,1) and (2, 2). Both input img and output output are of type uint8.
You can download the test image here (refer vandy.png downloaded file) to use in MATLAB.
Errors
Simple test:(error)
Variable output has an incorrect value.
Tested with a 5x5 uint8 matrix with all 255-s in the first and last rows and columns and zeros everywhere else and w = 1
Assessment result: (error)
incorrect Using image file
Variable output has an incorrect value.
Tested with the vandy.png file and w = 1
Simple Encryption
Simple Encryption
Caesar's cypher is the simplest encryption algorithm. It adds a fixed value to the ASCII (unicode) value of each character of a text. In other words, it shifts the characters. Decrypting a text is simply shifting it back by the same amount, that is, it substract the same value from the characters. Write a function called caesar that accepts two arguments: the first is the character vector to be encrypted, while the second is the shift amount. The function returns the output argument coded, the encrypted text. The function needs to work with all the visible ASCII characters from space to ~. The ASCII codes of these are 32 through 126. If the shifted code goes outside of this range, it should wrap around. For example, if we shift ~ by 1, the result should be space. If we shift space by -1, the result should be ~. Here are a few things you may want to try with MATLAB before starting on this assignment:
Errors for the following
caesar(' !"#tiny_mce_markeramp;()*+,-.0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~',243)
caesar('MATLAB is fun!',-122)
caesar('x = mean(1:90) + sum(rand(1,23)');',81)
caesar('MOOC-s are very useful',-104)
Attachment:- Program Assignment.rar