segment object(leaf) which is on the white paper using image processing

这一生的挚爱 提交于 2019-12-11 08:19:09

问题


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??

thank you

another example.

and the result I got is

By using

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

Then Is_defe is a mask to segment

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


回答1:


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

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



来源:https://stackoverflow.com/questions/21619604/segment-objectleaf-which-is-on-the-white-paper-using-image-processing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!