필터 지우기
필터 지우기

How to perform a thresholding operation on the gradient magnitude?

조회 수: 12 (최근 30일)
Eren
Eren 2016년 10월 29일
댓글: Eren 2016년 10월 29일
This is the rules:
A simple edge detector using gradient magnitude
1. Compute gradient vector at each pixel by convolving image with horizontal and vertical derivative filters
2. Compute gradient magnitude at each pixel
3. If magnitude at a pixel exceeds a threshold, report a possible edge point.
But I don't know how to apply threshold manually in matlab (step 3.). Can anyone help me?
im1 = rgb2gray(imread('dog.jpg'));
[gx,gy] = imgradientxy(im1);
[gmag,gdir] = imgradient(gx,gy);
imshow(gmag,[]);

채택된 답변

Image Analyst
Image Analyst 2016년 10월 29일
I think they wanted you to use imfilter() or conv2() to do it "manually". If you do want to go to a higher level, you should use imgradent() not imgradientxy - that gives you the magnitude directly. Then you can threshold it by adding this line:
binaryImage = gMag > someThresholdValue; % Threshold the image.
You don't need to do both imgradientxy() and imgradient().

추가 답변 (0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by