What is the output matrix after applying the Sobel edge detection on the given 3x3 image?
img = [10 10 10; 10 0 10; 10 10 10]; edges = edge(img, 'sobel'); disp(edges);
Remember Sobel detects edges by highlighting intensity changes in horizontal and vertical directions.
The Sobel operator detects edges by calculating gradients. The center pixel is darker, so edges appear around it, resulting in a cross shape of ones.
What happens if you increase the threshold parameter in the edge function in MATLAB?
Think about what a threshold does in filtering values.
Increasing the threshold means only stronger edges (higher gradient values) are kept, so fewer edges appear.
What error will this MATLAB code produce?
img = imread('cameraman.tif'); edges = edge(img, 'canny', 0.5, 2.0); imshow(edges);
Check the documentation for the edge function with Canny method: scalar threshold and sigma are valid arguments.
No error; the code runs correctly. For Canny, the third argument is a scalar threshold (MATLAB uses it to derive low/high thresholds), and the fourth is the Gaussian sigma.
Which option shows the correct syntax to apply Prewitt edge detection with a threshold of 0.3?
Check MATLAB documentation for the edge function's threshold parameter format.
The threshold is passed as the third positional argument as a scalar or two-element vector. Option C is correct syntax.
Given the binary image below, how many edge pixels will the Roberts operator detect?
img = [ 0 0 0 0 0; 0 1 1 0 0; 0 1 1 0 0; 0 0 0 0 0; ];
Code:
edges = edge(img, 'roberts'); n = nnz(edges);
Roberts operator detects edges by looking at diagonal differences between pixels.
The Roberts operator detects edges along diagonals. The 2x2 block of ones creates edges on all four sides diagonally, resulting in 8 edge pixels detected.
