Hello everyone. For example, how to identify a specific point in an image in a moving video as follows. The required video is also uploaded in zip format. If you are interested, you can discuss with me. Thank you all very much.

1 view (last 30 days)
The video screenshot is as follows:
  4 Comments
Wesley
Wesley on 31 Mar 2021
Edited: darova on 31 Mar 2021
1. Make the following definition
function d = tracking(video)
% Function: Track and display the moving target in the video
% Input: video-video to be tracked
% Output: d-difference image sequence
% Read in video images
if ischar(video)
avi = aviread(video);
pixels = double(cat(4,avi(1:2:end).cdata))/255;
clear avi
else
pixels = double(cat(4,video{1:2:end}))/255;
clear video
end
% Convert RGB image to grayscale image
nFrames = size(pixels,4);
for f = 1:nFrames
pixel(:,:,f) = (rgb2gray(pixels(:,:,:,f)));
end
[rows,cols]=size(pixel(:,:,1));
nrames=f;
% Make difference between two adjacent frames and convert the difference image into a binary image
for l = 2:nrames
d(:,:,l)=(abs(pixel(:,:,l)-pixel(:,:,l-1)));
k=d(:,:,l);
bw(:,:,l) = im2bw(k, .2);
bw1=bwlabel(bw(:,:,l));
imshow(bw(:,:,l))
hold on
% 标记运动物体的位置并显示
cou=1;
for h=1:rows
for w=1:cols
if(bw(h,w,l)>0.5)
toplen = h;
if (cou == 1)
tpln=toplen;
end
cou=cou+1;
break
end
end
end
disp(toplen);
coun=1;
for w=1:cols
for h=1:rows
if(bw(h,w,l)>0.5)
leftsi = w;
if (coun == 1)
lftln=leftsi;
coun=coun+1;
end
break
end
end
end
disp(leftsi);
disp(lftln);
widh=leftsi-lftln;
heig=toplen-tpln;
widt=widh/2;
disp(widt);
heit=heig/2;
with=lftln+widt;
heth=tpln+heit;
wth(l)=with;
hth(l)=heth;
disp(heit);
disp(widh);
disp(heig);
rectangle('Position',[lftln tpln widh heig],'EdgeColor','r');
disp(with);
disp(heth);
plot(with,heth, 'r*');
drawnow;
hold off
end
2.Track the image
clear data
disp('input video');
% Read in the video image samplevideo.avi and display ccbr1
avi=aviread('MVI_1069.avi');
video = {avi.cdata};
for a = 1:length(video)
imagesc(video{a});
axis image off
drawnow;
end
disp('output video');
% Call the tracking() function to track the moving target
tracking(video);
Wesley
Wesley on 31 Mar 2021
@darovaHow to define the extreme point or inflection point of the edge has become a difficult point, and it is difficult to achieve this goal.

Sign in to comment.

Answers (2)

darova
darova on 31 Mar 2021
Here is an example for extreme points: find points where derivative changes it's sign
clc,clear
x = 0:0.2:10;
y = sin(x);
dy = sign(diff(y)); % sign of derivative
c1 = abs(diff(dy)); % change of sign
ix1 = 1 + find(c1);
plot(x(ix1),y(ix1),'or')
line(x,y)
Read about curvature to find inflection points: LINK
Inflection point is a point where curvature changes its sign
  2 Comments
Image Analyst
Image Analyst on 1 Apr 2021
You have to be able to describe in words what is unique about the point(s) you want to find. Then you can develop an algorithm to find it(them). For example, the blob looks roughly like an upside down V and I want to find the highest point (lowest line or row number) of the dent in the bottom middle of the blob. If you have that, you can make an algorithm.

Sign in to comment.


Image Analyst
Image Analyst on 31 Mar 2021
The bounding box and centroid are easy - just call regionprops()
props = regionprops(binaryImage, 'Centroid', 'BoundingBox');
If you want any other locations, you'd have to somehow precisely define where they are. It depends on the shape. Are all the shapes like that arrowhead shape?
  4 Comments
Image Analyst
Image Analyst on 1 Apr 2021
OK, so the shape changes but is the thing you want to record the location of there in every shape? Post a few shapes and indicate the point(s) that you want to find.
Sure you can write a video from images or figures or axes. I'm attaching several demos that make videos.

Sign in to comment.

Categories

Find more on Visual Exploration in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!