Complete the code to read an image file named 'image.jpg'.
img = imread('[1]');
The imread function requires the filename as a string, so it must be enclosed in single quotes.
Complete the code to convert the image to grayscale.
gray_img = [1](img);im2bw which converts to binary, not grayscale.imadjust which adjusts contrast.The rgb2gray function converts a color image to grayscale.
Fix the error in the code to apply a 3x3 averaging filter to the grayscale image.
h = fspecial('[1]', [3 3]); filtered_img = imfilter(gray_img, h);
The correct filter type for averaging in fspecial is 'average'.
Fill both blanks to create a Gaussian filter with standard deviation 0.5 and apply it to the image.
h = fspecial('[1]', [2]); filtered_img = imfilter(img, h);
The fspecial function needs 'gaussian' as the filter type and the size of the filter as a vector like [3 3]. The standard deviation can be specified as a third argument if needed.
Fill all three blanks to create a Laplacian filter, apply it, and display the result.
h = fspecial('[1]'); filtered_img = imfilter([2], h); imshow([3]);
The Laplacian filter is created with 'laplacian', applied to the grayscale image, and the filtered image is displayed.
