Image analysis - fiber recognition

旧城冷巷雨未停 提交于 2019-12-21 04:32:14

问题


I am new to image analysis. Do you know how to binarize this image in such a way to get the fibers only?

I have tried different threshold techniques etc, but I was not successful. I do not mind what tool I should use but I prefer .NET or Matlab.

PS: I did not know where to put my answer, so I put it at StackOverflow.


回答1:


Based on the comments, it seems you are having difficulty translating the proposed Mathematica solutions into MATLAB. Here is my attempt:

@Nakilon solution

%# read image
I = im2double(imread('http://i.stack.imgur.com/6KCd1.jpg'));

%# ImageAdjust[]
II = I;
for k=1:size(II,3)
    mn = min(min( II(:,:,k) )); mx = max(max( II(:,:,k) ));
    II(:,:,k) = ( II(:,:,k) - mn ) ./ (mx-mn);
end

%# Sharpen[]
II = imfilter(II, fspecial('unsharp'));

%# MinDetect[], MaxDetect[]
II = rgb2gray(II);
mn = imextendedmin(II,0.3,8);
mx = imextendedmax(II,0.7,8);

%# pad image because Mathematica handles border cases differently than MATLAB
pad = 30;
q = padarray(mn, [pad pad], 'symmetric', 'both');

q = medfilt2(q, [5 5]*2+1, 'symmetric');                 %# MedianFilter[]
q = ordfilt2(q, 1, ones(2*5+1), 'symmetric');            %# MinFilter[]
q = ordfilt2(q, (25*2+1)^2, ones(25*2+1), 'symmetric');  %# MaxFilter[]
q = ordfilt2(q, 1, ones(20*2+1), 'symmetric');           %# MinFilter[]

%# un-pad image
q = q(pad+1:end-pad, pad+1:end-pad, :);

%# ImageSubtract[], ImageMultiply[], ImageAdd[]
a = imsubtract(mn,q)==1;    %# a = mn; a(q) = false;
b = immultiply(mx,q);       %# b = mx & q;
c = imadd(a,b);             %# c = a | b;

%# show images
figure(1)
subplot(121), imshow(mn)
subplot(122), imshow(mx)
figure(2), imshow(q)
figure(3)
subplot(121), imshow(a)
subplot(122), imshow(b)
figure(4), imshow(c)

Note that there are differences at the edges. In the Mathematica documentation, it vaguely says:

At the edges of an image, MedianFilter/MinFilter/MaxFilter uses smaller neighborhoods.

But there is no direct match for this behavior, instead MATLAB gives you the option to customize the padding at the boundaries of the images.


@belisarius solution

%# read image
I = im2double(imread('http://i.stack.imgur.com/6KCd1.jpg'));

%# LaplacianGaussianFilter[]
II = imfilter( I , fspecial('log', [2 2]*2+1, (2*2+1)/2) );

%# ImageAdjust[]
for k=1:size(II,3)
    mn = min(min( II(:,:,k) )); mx = max(max( II(:,:,k) ));
    II(:,:,k) = ( II(:,:,k) - mn ) ./ (mx-mn);
end

%# Binarize[]
BW = im2bw(II, 0.6);

%# DeleteSmallComponents[]
BW = bwareaopen(BW, 2, 8);

%# show images
figure
subplot(121), imshow(BW)
subplot(122), imshow( imoverlay(I,BW,[0 1 0]) )




回答2:


The following may help a bit (Code in Mathematica):

DeleteSmallComponents[
 Binarize[
   LaplacianGaussianFilter[i, 2],
 .6],
 2]

Image composition to show the matching:

ImageCompose[i, {i1, .4}] // ImageAdjust




回答3:


Try MinDetect and MaxDetect.

s = Sharpen @ ImageAdjust @ originalimage
{min, max} = {s~MinDetect~.3, s~MaxDetect~.7}
min~MedianFilter~5~MinFilter~5~MaxFilter~25~MinFilter~20
{min~ImageSubtract~%, max~ImageMultiply~%}
ImageAdd @@ %




回答4:


Read about Edge Detection. Thats what you need in this case. a threshold will not help you. Fibers (which are mostly straight) will be relatively easy to detect. But as there is a chapter on the Wikipedia site: "Why edge detection is a non-trivial task"...



来源:https://stackoverflow.com/questions/7387801/image-analysis-fiber-recognition

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