nonmaxsup function in matlab

Non-maximum suppression is a technique used in edge detection to thin out an edge in regions where the pixel intensity magnitude is not as strong as it should be. In MATLAB, there is a built-in function called nonmaxsup that can be used to perform non-maximum suppression on an image.

The function takes two inputs - the first input is the gradient magnitude image, and the second input is the gradient direction image. The output is a binary edge map where the edges have been thinned out by suppressing non-maximum pixels.

Here is an example usage of the nonmaxsup function:

main.m
% Read in image and perform edge detection
I = imread('cameraman.tif');
[Gx, Gy] = imgradientxy(I);
[Gmag, Gdir] = imgradient(Gx, Gy);

% Perform non-maximum suppression on edges
edgeMap = nonmaxsup(Gmag, Gdir);

% Display results
subplot(1,2,1), imshow(I), title('Original Image');
subplot(1,2,2), imshow(edgeMap), title('Edge Map after non-maximum suppression');
365 chars
12 lines

In this example, we first read in an image and perform edge detection using the imgradientxy and imgradient functions. We then pass the gradient magnitude and direction images to the nonmaxsup function to thin out the edges. Finally, we display the original image and the resulting edge map after non-maximum suppression using the imshow function.

gistlibby LogSnag