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

Unfinished MatLab Code: im = imread(\'lena.bmp\'); [r, c]=size(im); im=double(im

ID: 3592317 • Letter: U

Question

Unfinished MatLab Code:


im = imread('lena.bmp');
[r, c]=size(im);
im=double(im);
outim= % Your code here:initialize output image;
LOGfilter= % Your code here: 5*5 log filter;
for i= % Your code here;
    for j= % Your code here;
        for n= % Your code here;
            for m= % Your code here;
                outim(i,j)= % Your code here;                  
            end
        end      
    end
end
figure(1)
subplot(1,2,1)
imshow(uint8(im))
subplot(1,2,2)
imshow(uint8(outim));

As Laplacian filter can detect edges as well as noise, it may be desirable to smooth the image first by a Gaussian filter to suppress the noise before using Laplacian for edge detection. Laplacian of Gaussian (LOG) filter is a combination of Laplacian filter and Gaussian filter. The 5*5 LOG filter is defined as below 1 2 -16 2 1 Please complete the provided Matlab code to apply LOG filtering.

Explanation / Answer

img = double(imread('cameraman.tif')); Log_filter = fspecial('log', [5,5], 4.0); % fspecial creat predefined filter.Return a filter. % 25X25 Gaussian filter with SD =25 is created. img_LOG = imfilter(img, Log_filter, 'symmetric', 'conv'); imshow(img_LOG, []);