2

I have tried to extract the dark line inside very noisy images without success. Some tips?

enter image description here

enter image description here

enter image description here

My current steps for the first example:

1) Clahe: with clip_limit = 10 and grid_size = (8,8)

2) Box Filter: with size = (5,5)

3) Inverted Image: 255 - image

4) Threshold: when inverted_image < 64

UPDATE

I have performed some preprocessing steps to improve the quality of tested images. I adjusted my ROI mask to crop top and down (because they are low intensities) and added a illumination correction to see better the line. Follow below the current images:

enter image description here

enter image description here

enter image description here

  • Provide more information regarding your approach. What have worked and what have not. – Michał Gacka Mar 29 '17 at 17:20
  • Sure, @m3h0w. My current steps: 1) [Clahe](http://imgur.com/788brQ5): with clip_limit = 10 and grid_size = (8,8) 2) [Box Filter](http://imgur.com/XC1zpXo): with size = (5,5) 3) [Inverted Image](http://imgur.com/QB61ZvX) 4) [Threshold](http://imgur.com/L7g9hVI): when inverted_image < 64 – Rômulo Cerqueira Mar 29 '17 at 17:33
  • I would like to use RANSAC to detect the dark line, but I need to "clean" the image before this step. – Rômulo Cerqueira Mar 29 '17 at 17:38
  • You should update the question and preferably provide some images of the results. – Michał Gacka Mar 29 '17 at 17:46
  • I improved the question. – Rômulo Cerqueira Mar 29 '17 at 17:51
  • @m3h0w, any comments here? – Rômulo Cerqueira Mar 30 '17 at 17:46
  • Well I have some ideas but no time to implement them. The end of march is really bussy for me. First of all, I think that you don't have control over the processing that you're trying to use. You need to experiment more with the values (I recommend trackbars and changing them dynamically to really see what's going on). You're processing makes the line less visible, which is not good. I'd think about finding the edge on the bottom, iterating every 0.5cm and calculating sum of pixels in every direction (every 5 degrees or so) on the inv. of the image. The biggest sum should be the line. – Michał Gacka Mar 30 '17 at 19:18
  • @m3h0w, I followed your guidelines and improve my preprocessing steps (see on topic). – Rômulo Cerqueira Mar 31 '17 at 18:12

1 Answers1

0

Even though the images are noisy, you are only looking for straight lines towards the north of image. So, why don't use some kind of matched filter with morphological operations?

EDIT: I have modified it.

1) Use median filter along the x and y axis, and normalize the images. 2) Matched filter with all possible orientations of lines.

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

enter image description here

enter image description here

enter image description here

enter image description here

Ozcan
  • 726
  • 4
  • 13