使用图像处理在白纸上的片段对象(叶子) [英] segment object(leaf) which is on the white paper using image processing

查看:323
本文介绍了使用图像处理在白纸上的片段对象(叶子)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从图像中获取叶子。
背景是普通白纸(A4)并且有一些阴影。

I want to get only leaf from an image. The background is a normal white paper(A4) and there is some shadow.

我应用了一些方法(结构元素,使用滤镜的边缘检测)但是我找不到可以应用所有图像的一般方法。

I apply some method (structure element,edge detection using filter) but I cannot find the general way which can apply all the image.

这些是示例。

these are examples.

这个问题有更好的方法吗?

Are there better methods for this problem??

谢谢

另一个例子。

another example.

和结果我得到的是

and the result I got is

使用

hsv_I = rgb2hsv(I);
Is = hsv_I(:,:,2);
Is_d = imdilate(Is,strel('diamond',4));
Is_e = imerode(Is,strel('diamond',2));
Is_de = imerode(Is_d,strel('disk',2));
Is_def = imfill(Is_de,'holes');
Is_defe = imerode(Is_def,strel('disk',5));

然后Is_defe是分段
的掩码

Then Is_defe is a mask to segment

但我所做的方法非常具体。我一般不能使用它。

But the method that i did is very specific. I cannot use this in general.

推荐答案

如果你有图像处理工具箱,你可以这样做:

If you have the Image Processing Toolbox, you could do as follows:

下面的代码首先用函数 graythresh ,使用 imfill 功能。假设是一个包含RGB图像的单元格:

The code below first estimates the threshold with the function graythresh, thresholds the image and fills holes with the imfill function. Suppose I is a cell containing your RGB images:

for k=1:length(I)
    t=graythresh(rgb2gray(I{k}));
    BW{k}=imfill(~im2bw(I{k}, t), 'holes');
    subplot(length(I),1,k), imshow(BW{k});
end

这篇关于使用图像处理在白纸上的片段对象(叶子)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆