我有以下图像:
任务是获取木头的红色边框:
我尝试了以下方法:
基于强度的细分
img = im2double(imread('img.jpg'));
IDG1 = rgb2gray(img); % conver to gray scale
t = 100; % set a thresholding value
IT = im2bw(IDG1, t/255); % apply the threshold
I2 = ~IT; % get a negative image
I3 = bwareaopen(I2,70); % get rid of small unwanted pixels
figure, imshow(I3);
Canny / Prewitt的优势,但效果不佳。如何消除噪音并获得清晰的边缘?
edgeim = edge(I3,'Prewitt');
figure, imshow(edgeim); % truesize(1)