Department of Engineering and Technology Signal and Linear System Analysis Extra Activity Convolution masks I hereby declare that I have worked on this homework with academic integrity Introduction For this activity we were asked to perform an edge detector filter, show the original image and the resulting one, the code had to use a convolution and not use the functions MATLAB has already integrated. Methodology First, I investigated different ways to create a mask using matrix and then translate that in MATLAB language. I ended up finding 3 different methods which presented similarities between each other. I started my scrip by assigning the image that the program is going to use, MATLAB usually makes images a 3 axis matrix (Ex: 3x3x3) so I transformed the image into a 2 dimensional matrix. The first method is the Sobel Operation Mask, which stablish two matrices of 3x3. One matrix for the vertical vertex and other for the horizontal vertex (“x” and “y” axis). The image is passed through a convolution, one for each axis. After both axis have been passed through the convolution, a variable that adds both axis is assigned and then output is plotted. The second method is the Robert’s cross operation Mask. Like Sobel’s method two matrix are made for each axis, but these matrices have a size of 2x2, this have the effect of outputting thinner lines when the mask is applied to the image. The third method is the most efficient method, which is the Laplacian of Gaussian method. This operation uses just one matrix of 3x3 and just one convolution is needed to create the mask. The Laplacian of an image with a two-dimensional pixel values can be given by a second derivate measurement on the image, at the same time this makes the mask more sensitive to noise than the other methods. As the convolution operation is associative, I could add a gaussian smoothing filter to obtain a better mask, sadly my to accomplish this you need an Image processing Toolbox. Nevertheless, the method still works without the Gaussian filter. Finally, I plotted the image and the different mask to compared the results. Script % David Benavides Banda 371557 % I hereby declare that i have worked on this activity with integrity. % References: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.301.927&rep=r ep1&type=pdf clc clear %Images I=imread('atari.jpg'); I2=I(:,:,1); %Sobel Operation Mask GSx=[-1 0 1; -2 0 2; -1 0 1]; GSy=[1 2 1; 0 0 0; -1 -2 -1]; Sx=conv2(I2,GSx,'same'); Sy=conv2(I2,GSy,'same'); Sobel Op S=abs(Sx)+abs(Sy); %Sobel Op matrix for Gx and GY %Convolution of X and Y axis for %Robert's cross Operation Mask GRx=[1 0; 0 -1]; and GY GRy=[0 1; -1 0]; Rx=conv2(I2,GRx,'full'); Ry=conv2(I2,GRy,'full'); Robert's cross R=abs(Rx)+abs(Ry); %Robert's cross Op matrix for Gx %Convolution of X and Y axis for %Laplacian of Gaussian Mask MLG=[-1 -1 -1; -1 8 -1; -1 -1 -1]; Iblur1=imgaussfilt(I2,2) LG=conv2(I2,MLG,'valid'); %Plots figure('Name','face 1') subplot(2,2,1) imshow(I) title('Original') subplot(2,2,2) imshow(S) title('Sobel Op Mask') subplot(2,2,3) imshow(R) title('Robert´s cross Op Mask') subplot(2,2,4) imshow(LG) title('Laplacian of Gaussian Mask') Results As can be seen the different masks worked, and the clearest one is the Laplacian mask, the Robert’s cross is the second best one. The Sobel Op makes lines thicker which makes the mask look saturated. Conclusion The masks worked correctly, MATLAB have functions which makes more optimized masks. Nevertheless, the ones made with this procedure work really well. Also, if I had the image processing toolbox I could program a better mask with the Laplacian of Gaussian Mask References: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.301.927&rep=r ep1&type=pdf https://la.mathworks.com/help/images/apply-gaussian-smoothing-filtersto-images.html