我试图在非常嘈杂的图像中提取暗线而没有成功。一些提示?
我对第一个例子的当前步骤:
1)Clahe:with clip_limit = 10 and grid_size =(8,8)
2)Box Filter:尺寸=(5,5)
3)Inverted Image:255 - image
4)Threshold:当inverted_image< 64
我已经执行了一些预处理步骤来提高测试图像的质量。我调整了我的ROI模板以自上而下(因为它们是低强度)并添加了照明校正以更好地看到线条。按照下面的当前图片:
答案 0 :(得分:0)
即使图像有噪音,您也只能寻找图像北侧的直线。那么,为什么不使用某种匹配滤波器进行形态学运算呢?
编辑:我修改了它。1)沿x和y轴使用中值滤波器,并对图像进行归一化。 2)匹配滤波器,具有所有可能的线方向。
% im=imread('JwXON.png');
% im=imread('Fiy72.png');
% im=imread('Ya9AN.png');
im=imread('OcgaIt8.png');
imOrig=im;
matchesx = fl(im, 1);
matchesy = fl(im, 0);
matches = matchesx + matchesy;
[x, y] = find(matches);
figure(1);
imagesc(imOrig), axis image
hold on, plot(y, x, 'r.', 'MarkerSize',5)
colormap gray
%----------
function matches = fl(im, direc)
if size(im,3)~=1
im = double(rgb2gray(im));
else
im=double(im);
end
[n, m] = size(im);
mask = bwmorph(imfill(im>0,'holes'),'thin',10);
indNaN=find(im==0); im=255-im; im(indNaN)=0;
N = n - numel(find(im(:,ceil(m/2))==0));
N = ceil(N*0.8); % possible line length
% Normalize the image with median filter
if direc
background= medfilt2(im,[1,30],'symmetric');
thetas = 31:149;
else
background= medfilt2(im,[30,1],'symmetric');
thetas = [1:30 150:179];
end
normIm = im - background;
normIm(normIm<0)=0;
% initialize matched filter result
matches=im*0;
% search for different angles of lines
for theta=thetas
normIm2 = imclose(normIm>0,strel('line',5,theta));
normIm3 = imopen(normIm2>0,strel('line',N,theta));
matches = matches + normIm3;
end
% eliminate false alarms
matches = imclose(matches,strel('disk',2));
matches = matches>3 & mask;
matches = bwareaopen(matches,100);