Detection of an autonomous seam in images on Matlab

I am trying to detect seams in welding images for an autonomous welding process. enter image description here I want to find the pixel positions of the detected line (the red line in the desired image) in the original image.

I used the following code and finally removed the noise from the image to get the result below.

clc,clear,clf;
im = imread('https://i.stack.imgur.com/UJcKA.png');
imshow(im);title('Original image'); pause(0.5);
sim = edge(im, 'sobel');
imshow(sim);title('after Sobel'); pause(0.5);
mask = im > 5;
se = strel('square', 5);
mask_s = imerode(mask, se);
mask(mask_s) = false;
mask = imdilate(mask, se);
sim(mask) = false;
imshow(sim);title('after mask');pause(0.5);
sim= medfilt2(sim);
imshow(sim);title('after noise removal')

enter image description here

Unfortunately, there is nothing in the image to find a seam.

Any help would be appreciated.

Download Original Image.

+4
source share
2 answers

You need to make the filter more resistant to noise. This can be done with great support:

filter = [ones(2,9);zeros(1,9);-ones(2,9)];
msk = imerode(im > 0, ones(11));  % only object pixels, discarding BG
fim =imfilter(im,filter); 
robust = bwmorph((fim>0.75).*msk,'skel',inf); % get only strong pixels

:

enter image description here

, , :

st = regionprops(bwlabel(robust,8), 'Area', 'PixelList');
[ma mxi] = max([st.Area]); % select the region with the largest area

(2- ) :

pp=polyfit(st(mxi).PixelList(:,1), st(mxi).PixelList(:,2), 2);

:

imshow(im, 'border','tight');hold on;
xx=1:size(im,2);plot(xx,polyval(pp,xx)+2,'r');

enter image description here

+2 Y - .


PS,
.

+3

, , .

Wikipedia , , . , :

. . medfilt2 3x3. 3x3 ,

Window layout

3x3 [212 157]

 [0 0 0
  1 1 1
  0 0 0]

0! , , .

Shai . , Matlab bwareaopen, .

,

sim= medfilt2(sim);

sim= bwareaopen(sim, 4);

after noise removal

. , . , . Sobel, Matlab , , . , ( bwareaopen), .

Detector Comparison

+3

Source: https://habr.com/ru/post/1664162/


All Articles