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

1 view (last 30 days)
Mina Husseinpour
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.
  2 Comments
Image Analyst
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?

Sign in to comment.

Accepted Answer

yanqi liu
yanqi liu on 1 Nov 2021
Edited: yanqi liu on 1 Nov 2021
sir,please check the follow code to get some information
% This code opens all the frames of the video and pre-precesses them
clc
clear all
close all
%%
% Read the video file
V = VideoReader('video.mpg');
fcount = 0;
while hasFrame(V)
frame = readFrame(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
  4 Comments

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!