Looking for a suitable image and video processing method for seam tracking

2 views (last 30 days)
Mina Husseinpour on 31 Oct 2021
Edited: yanqi liu on 3 Nov 2021
Hi everybody, I am trying to implement a seam tracking algorithm using image processing (please check attached files); I have tried many methods that are working but I still think that I can do better (yet my codes aren't always working properly and I get some bugs). I attach images and if you want to see a video of the process please contact me (husseinpourmina@gmail.com) I want two detect the disks and mark a point between them as the seam. ROI is shown in the circle and the pixels that are on the left side of the red line, are not a part of ROI and must be ignored and I need to track the green point in a live video. (If you think you can help me, please email me to send a video file.) P.S: I attached the file of my code, please check and leave a comment if you know a better way to track the seam position.
Image Analyst on 31 Oct 2021
What exactly is the disc? Is it the dumbbell-shaped blob in the middle? What do you need to measure? The weighted centroid of the dumbbell for each frame?

yanqi liu on 1 Nov 2021
Edited: yanqi liu on 1 Nov 2021 % This code opens all the frames of the video and pre-precesses them
clc
clear all
close all
%%
fcount = 0;
while hasFrame(V)
im = rgb2gray(frame);
bw = im2bw(im, 0.8);
[L,num] = bwlabel(bw);
stats = regionprops(L);
for j = 1 : num
recti = stats(j).BoundingBox;
% target filter
if recti(4)>size(bw,1)*0.1 || recti(2) < size(bw,1)*0.3
bw(L==j) = 0;
end
end
[~,num] = bwlabel(bw);
if num < 2
bw = im2bw(im, 0.85);
[L,num] = bwlabel(bw);
stats = regionprops(L);
for j = 1 : num
recti = stats(j).BoundingBox;
% target filter
if recti(4)>size(bw,1)*0.1 || recti(2) < size(bw,1)*0.3
bw(L==j) = 0;
end
end
end
bw = logical(bw);
% other filter
bw2 = imclose(bw, strel('line', round(size(bw,1)*0.2), 90));
bw2 = bwareaopen(bw2, 100);
[r,c] = find(bw2);
[~,ind] = min(c);
if ~isempty(ind)
bw2 = bwselect(bw2, c(ind), r(ind));
bw = logical(bw.*bw2);
end
[L,num] = bwlabel(bw);
if num > 2
bw = bwareaopen(bw, 3);
[L,~] = bwlabel(bw);
end
stats = regionprops(L);
rects = cat(1, stats.BoundingBox);
[~,ind] = sort(rects(:,2));
bw(L~=ind(1)&L~=ind(2)) = 0;
bw = logical(bw);
[L,num] = bwlabel(bw);
stats = regionprops(L);
cens = cat(1, stats.Centroid);
frame2 = insertMarker(frame,cens,'x','color','red','size',6);
figure(1); imshow(frame2, []);
fcount = fcount +1
title(num2str(fcount));
pause(0.00001);
end
yanqi liu on 3 Nov 2021

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
{"ft_lang_label":"__label__en","ft_lang_prob":0.72596484,"math_prob":0.9860742,"size":2897,"snap":"2022-05-2022-21","text_gpt3_token_len":920,"char_repetition_ratio":0.09609402,"word_repetition_ratio":0.117154814,"special_character_ratio":0.31860545,"punctuation_ratio":0.16899225,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.976218,"pos_list":[0,1,2],"im_url_duplicate_count":[null,1,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-01-29T10:42:54Z\",\"WARC-Record-ID\":\"<urn:uuid:6bbeb3d1-4fe7-45c9-8572-1642ec554420>\",\"Content-Length\":\"170729\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:c0028583-61ef-443d-9b60-63fb82ea7434>\",\"WARC-Concurrent-To\":\"<urn:uuid:b6004081-6121-4f85-be73-d79909cab621>\",\"WARC-IP-Address\":\"184.25.188.167\",\"WARC-Target-URI\":\"https://ch.mathworks.com/matlabcentral/answers/1575808-looking-for-a-suitable-image-and-video-processing-method-for-seam-tracking?s_tid=prof_contriblnk\",\"WARC-Payload-Digest\":\"sha1:HHGJ4GARY4RNNEUBRNZOUHGOB2OSKA2O\",\"WARC-Block-Digest\":\"sha1:HPSLZJ4BQAPDOXUGLRUKUXK6BGIY5XF4\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-05/CC-MAIN-2022-05_segments_1642320304883.8_warc_CC-MAIN-20220129092458-20220129122458-00514.warc.gz\"}"}