[SOLVED] Matlab Assignment 1

30.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon A1-qa8anp.zip (3276.7 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
Rate this product

Problem 1:
The objective of this part of the project is to understand and apply image

filtering and edge detection

Instructions on how to read image files into MATLAB are given in Implementation Notes section.

P1.1: Read the image ‘cameraman.tif’. This image is copied in your MATLAB directory when you install MATLAB. Find gradient of this image using imgradient MATLAB function. Display angles of gradient as a 2D map.

P1.2: Read the image ‘lines.png’ and display it. This image has been provided along with the handout for this project.

This image has several lines drawn at different angles. We are interested in finding a 3×3 convolution filter, which when applied to the image, only returns the line(s) at 45 deg from the x-axis.

In other words, the convolution filter should return high values when applied on a line drawn at 45 deg from the x-axis, and return low values otherwise. Using your filter, locate the line along 45 deg.

P1.3: Read the cameraman image again, denoted as X, this time apply the simplest edgedetectorF =􏰂1 0 −1􏰃onittofindY.
Is it possible to go back to retrieve X from Y ? Given that yn = xn−1 − xn+1, can you express X in terms of Y . Can you design a 3×3 filter G that performs the opposite of F ? If yes, provide the 3×3 filter. If no, provide a proof showing such a filter does not exist.

2

Implementation Notes

MATLAB has an extensive help available online. If some MATLAB command is missing here, or for more details on any of these commands, you can use MATLAB’s help at www.mathworks.com

f=imread(’MyImageFileIn.tif’);% Read an image file
imwrite(f,’MyImageFileOut.tif’);% Write an image file
imagesc(f);colormap(gray);colorbar;% Display an image
imshow(f);% Display an image
hist(f(:),[0:255]);% Display histogram of the read image
grayimg=rgb2gray(colorimg);% Convert a color image to gray
scale
Filt=[0,1,0;1,0,1;0,1,0];
g=imfilter(f,Filt);% Filter an image f to produce g
[camMag,camAng]=imgradient(I);% Compute the magnitude and angle
of the gradient of an image
F=fft2(f);
F=fftshift(F);
imagesc(abs(F))% Find 2D FFT F(u,v) of an image f(x,y)
 % Sometimes the dynamic range of FFT is too large, so you may
see one or two impulses only while actually there is more.  To
see such a FFT, use imagesc(log(abs(F))) to squeeze the dynamic
range.
fr=ifft2(ifftshift(F));
imagesc(abs(fr))% Find Inverse 2D FFT fr(x,y) of a 2D FFT
F(u,v)

surf(X,Y,Z)% Plot a surface Z=f(X,Y)
imhist(f) or hist(f(:))% Plot histogram of image f

  • A1-qa8anp.zip