Image filtering is a process that modifies or enhances an image by applying a filter (a matrix) to the image pixels, often to reduce noise or highlight features.
Click to reveal answer
beginner
What MATLAB function is commonly used for applying a 2D filter to an image?
The function imfilter() is commonly used to apply 2D filters to images in MATLAB.
Click to reveal answer
intermediate
Explain the difference between a low-pass and a high-pass filter in image filtering.
A low-pass filter smooths the image by reducing high-frequency details (like noise), while a high-pass filter enhances edges and fine details by emphasizing high-frequency components.
Click to reveal answer
intermediate
What does the 'replicate' option do in the imfilter() function?
The 'replicate' option pads the image borders by replicating the edge pixels, which helps avoid artifacts when filtering near edges.
Click to reveal answer
beginner
How can you create a simple averaging filter in MATLAB?
You can create an averaging filter using fspecial('average', [m n]), where m and n define the filter size.
Click to reveal answer
Which MATLAB function applies a filter to an image?
Aimwrite
Bimfilter
Cimshow
Dimread
✗ Incorrect
imfilter applies a filter to an image. imread reads images, imshow displays images, and imwrite saves images.
What does a low-pass filter do to an image?
AInverts colors
BSharpens edges
CSmooths the image
DAdds noise
✗ Incorrect
A low-pass filter smooths the image by reducing noise and fine details.
Which option in imfilter replicates edge pixels for padding?
A'replicate'
B'symmetric'
C'circular'
D'zero'
✗ Incorrect
The 'replicate' option pads by copying edge pixels to avoid border artifacts.
How do you create an averaging filter of size 3x3 in MATLAB?
Afspecial('average', [3 3])
Bfspecial('gaussian', 3)
Cimfilter('average', 3)
Dfilter2('average', [3 3])
✗ Incorrect
fspecial('average', [3 3]) creates a 3x3 averaging filter.
What is the main purpose of image filtering?
ATo change image file format
BTo display the image
CTo compress the image
DTo modify or enhance image features
✗ Incorrect
Image filtering modifies or enhances image features like noise reduction or edge detection.
Describe how you would apply a smoothing filter to an image in MATLAB.
Think about creating the filter first, then applying it with imfilter.
You got /3 concepts.
Explain the difference between low-pass and high-pass filters in image filtering.
Consider what details each filter affects in the image.
You got /3 concepts.
Practice
(1/5)
1. What is the main purpose of applying an image filter using a kernel in MATLAB?
easy
A. To convert the image to grayscale
B. To modify the image by emphasizing or reducing certain features
C. To increase the image file size
D. To change the image file format
Solution
Step 1: Understand what a kernel does
A kernel is a small matrix used to process an image by changing pixel values based on neighbors.
Step 2: Identify the effect of filtering
Filtering modifies the image to highlight edges, blur, or sharpen features, not file format or size.
Final Answer:
To modify the image by emphasizing or reducing certain features -> Option B
Quick Check:
Image filtering changes features = D [OK]
Hint: Filters change image features, not file type or size [OK]
Common Mistakes:
Confusing filtering with file format conversion
Thinking filtering changes image size
Assuming filtering only converts to grayscale
2. Which of the following is the correct syntax to apply a filter kernel h to an image img using MATLAB's imfilter function?
easy
A. filtered_img = filter(h, img);
B. filtered_img = filter(img, h);
C. filtered_img = imfilter(h, img);
D. filtered_img = imfilter(img, h);
Solution
Step 1: Recall MATLAB's imfilter syntax
The correct syntax is imfilter(image, kernel), where the image is first and kernel second.
Step 2: Check each option
filtered_img = imfilter(img, h); matches the correct syntax. Options B and D use 'filter' which is incorrect. filtered_img = imfilter(h, img); reverses arguments.
Final Answer:
filtered_img = imfilter(img, h); -> Option D
Quick Check:
imfilter(image, kernel) = A [OK]
Hint: imfilter(image, kernel) is the correct order [OK]
fspecial('average', 3) creates a 3x3 averaging filter, which is valid.
Step 2: Check imfilter usage
imfilter supports RGB images and 'same' option returns output same size as input.
Final Answer:
No error; the code runs correctly -> Option A
Quick Check:
fspecial + imfilter with 'same' = A [OK]
Hint: imfilter works with color images and 'same' option [OK]
Common Mistakes:
Assuming imfilter only works on grayscale
Thinking 'same' is invalid option
Believing kernel size must be odd but 3 is odd and valid
5. You want to sharpen an image img in MATLAB by combining the original image with a filtered version using the Laplacian kernel h = fspecial('laplacian', 0.2);. Which code snippet correctly applies this sharpening?
hard
A. sharpened = img - imfilter(img, h, 'replicate');
B. sharpened = img + imfilter(img, h, 'replicate');
C. sharpened = imfilter(img, h, 'replicate') - img;
D. sharpened = imfilter(img, h, 'replicate') + img * 0.2;
Solution
Step 1: Understand Laplacian sharpening
Sharpening = original image minus the Laplacian filtered image to enhance edges.
Step 2: Match code to formula
sharpened = img - imfilter(img, h, 'replicate'); subtracts the filtered image from original, correctly applying sharpening.
Final Answer:
sharpened = img - imfilter(img, h, 'replicate'); -> Option A
Quick Check:
Sharpen = img - Laplacian filtered img = B [OK]
Hint: Sharpen by subtracting Laplacian filtered image [OK]
Common Mistakes:
Adding instead of subtracting Laplacian result
Multiplying original image incorrectly
Confusing Laplacian with averaging filter
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.