用红色获得优势

时间:2018-07-29 20:07:01

标签: image matlab image-processing

我有以下图像:

enter image description here

任务是获取木头的红色边框:

enter image description here

我尝试了以下方法:

基于强度的细分

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); 

enter image description here

Canny / Prewitt的优势,但效果不佳。如何消除噪音并获得清晰的边缘?

edgeim = edge(I3,'Prewitt');
figure, imshow(edgeim); % truesize(1)

enter image description here

1 个答案:

答案 0 :(得分:1)

您可以使用中值滤波器(r = 7),然后使用Sobel滤波器。这将为您提供以下图像: enter image description here 如果在此图像上使用二值化,将得到: enter image description here

要在MatLab中实现此目的,可以使用以下功能:

session.add(b)
session.commit()
# no error

有关更多信息,您可以查看以下来源:IIIIII