CA5_F18_sol.pdf - UCLA Dept of Electrical Engineering EE 114 Fall 2018 Computer Assignment 5 Solutions Matlab code We need to write the following of

# CA5_F18_sol.pdf - UCLA Dept of Electrical Engineering EE...

This preview shows page 1 - 4 out of 4 pages.

1 UCLA Dept. of Electrical Engineering EE 114, Fall 2018 Computer Assignment 5: Solutions Matlab code We need to write the following of m-files: GenerateGaussian.m function h = GenerateGaussian (size, lambda) % this function generates a Gaussian matrix % generate the meshgrid and the Gaussian matrix % [x,y]= meshgrid([- size / 2 : 1 : size / 2]) ; h = exp( - (x .* x + y .*y) / lambda); % find the sum and normalize the matrix sum_total = sum(sum(h)); h = h ./ sum_total; ConvolveImages.m function out = ConvolveImages (image, h) % this function convolves two images and % crop the result to the size of the first one % get the dimensions of the input images [y_i, x_i] = size(image); [y_h, x_h] = size ( h); % convolve the images out = uint8(conv2(image, h)); %crop it to the correct size out = imcrop(out, [(x_h + 1)/ 2, (y_h + 1) / 2 , x_i 1, y_i 1]) ; PSNR.m function psnr = PSNR (i1, i2)    #### You've reached the end of your free preview.

Want to read all 4 pages?

• Spring '11
• VanSchaar
• • • 