How can i track points in two images?

16 views (last 30 days)
Currently i fed two points to the first image,how i know where those points locate on a second image?
if true
originalRGBImage = imread('a.png');
imshow(originalRGBImage) ;
hold on
% GEt boundary of the human
[boundary_y,boundary_x] = find(~I) ;
idx = boundary(boundary_x,boundary_y) ;
% Boundary points
boundary_x = boundary_x(idx) ; boundary_y =boundary_y(idx) ;
imshow(I) ;
hold on
%draw boundary line
plot(boundary_x,boundary_y,'b') ;
%Get Tracking Points from the user
uiwait(msgbox('Locate the starting point of the neck '));
[neck_X,neck_Y] = ginput(1);
loacationEar=plot(neck_X,neck_Y,'r+', 'MarkerSize', 10);
uiwait(msgbox('Locate the starting point of your spine?'));
[spine_X,spine_Y] = ginput(1);
loacationSpine=plot(spine_X,spine_Y,'r+', 'MarkerSize', 10);
uiwait(msgbox('Locate the point in your knee?'));
[knee_X,knee_Y] = ginput(1);
hold on;
loacationknee1=plot(knee_X,knee_Y,'r+', 'MarkerSize', 10);
uiwait(msgbox('Locate the point in below the knee2?'));
[belowKnee_X,belowKnee_Y] = ginput(1);
loacationknee2=plot(belowKnee_X,belowKnee_Y,'r+', 'MarkerSize', 10);
uiwait(msgbox('Locate the point in above the knee through the thie?'));
[aboveKnee_X,aboveKnee_Y] = ginput(1);
loacationknee3=plot(aboveKnee_X,aboveKnee_Y,'r+', 'MarkerSize', 10);
I = im2bw(originalImage);
[boundary_y,boundary_x] = find(~I) ;
idx = boundary(boundary_x,boundary_y)
% Boundary points
boundary_x = boundary_x(idx) ; boundary_y =boundary_y(idx) ;
%draw boundary line
plot(boundary_x,boundary_y,'b');
end
Image which i fed Points
Image which i need to find where those above points in locate?
  4 Comments
KALYAN ACHARJYA
KALYAN ACHARJYA on 27 May 2018
Are both images are of the same size?
cha bha
cha bha on 27 May 2018
yes.same size. Actually its a 2 frames in a video,Only difference is human body lift more than first image

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 27 May 2018
Maybe try surf() in the Computer Vision System Toolbox. Feature based object detection
  9 Comments
cha bha
cha bha on 27 May 2018
Is there a way to do with above mention scenario using KLT Algorithm?
if true
videoFileReader = vision.VideoFileReader('deadlift.mp4');
videoPlayer = vision.VideoPlayer('Position',[1,10,1280,720]);
objectFrame = videoFileReader();
% objectRegion = [264,122,93,93];
%
figure;
imshow(objectFrame);
% objectRegion=round(getPosition(impoint));
% Show initial frame with a red bounding box.
objectImage = insertMarker(objectFrame,'+',objectRegion,'Color','red');
figure;
imshow(objectImage);
title('Red box shows object region');
points = detectMinEigenFeatures(rgb2gray(objectFrame));
pointImage = insertMarker(objectFrame,points.Location,'+','Color','white');
figure;
imshow(pointImage);
title('Detected interest points');
tracker = vision.PointTracker('MaxBidirectionalError',1);
initialize(tracker,points.Location,objectFrame);
while ~isDone(videoFileReader)
frame = videoFileReader();
[points,validity] = tracker(frame);
out = insertMarker(frame,points(validity, :),'+');
videoPlayer(out);
disp(points);
end
end
I try with this,but not able to do add points manually to this code,Is there way to add points manually to this KLT algorithm?
cha bha
cha bha on 27 May 2018
https://in.mathworks.com/matlabcentral/answers/402726-how-can-i-track-points-in-two-images#comment_572451 I tried with above code but didnt get any result on top of the image.I get somwthing like this,
How to check whether below shown part was straight or not?

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 27 May 2018
Try this:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clearvars;
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
fullFileName = 'D:\Matlab\work\Tests\image2.png';
[folder, baseFileName, ext] = fileparts(fullFileName);
%=======================================================================================
% Read in demo image.
rgbImage = imread(fullFileName);
% Shrink it to speed it up
% rgbImage = imresize(rgbImage, 0.75);
% Get the dimensions of the image.
[rows, columns, numberOfColorChannels] = size(rgbImage);
% Display the original image.
subplot(2, 3, 1);
imshow(rgbImage, []);
axis on;
caption = sprintf('Original Color Image, %s', baseFileName);
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
hp = impixelinfo(); % Set up status line to see values when you mouse over the image.
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0.05 1 0.95]);
% Get rid of tool bar and pulldown menus that are along top of figure.
% set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
% Convert to a grayscale image by taking the min of all 3 color channels.
grayImage = min(rgbImage, [], 3);
% Display the original image.
subplot(2, 3, 2);
imshow(grayImage, []);
axis on;
caption = sprintf('Gray Scale Image, %s', baseFileName);
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
hp = impixelinfo(); % Set up status line to see values when you mouse over the image.
% Compute the histogram
subplot(2, 3, 3);
histogram(grayImage, 'BinWidth', 1);
grid on;
% Find the big central blob
mask = grayImage < 200;
% Fill the image.
mask = imfill(mask, 'holes');
% Extract just the biggest blobs.
mask = bwareafilt(mask, 1);
% Display the mask image.
subplot(2, 3, 4);
imshow(mask, []);
axis on;
caption = sprintf('Thresholded image');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
hp = impixelinfo(); % Set up status line to see values when you mouse over the image.
% Find the top row in each column
topRow = ones(1, columns); % Preallocate.
for col = 1 : columns
thisColumn = mask(:, col);
tr = find(thisColumn, 1, 'first');
if ~isempty(tr)
topRow(col) = find(thisColumn, 1, 'first');
end
end
subplot(2, 3, 5);
plot(topRow, 'b-', 'LineWidth', 2);
grid on;
xlabel('column', 'FontSize', 20);
ylabel('Top most row', 'FontSize', 20);
% Plot over original image.
subplot(2, 3, 6);
imshow(rgbImage, []);
axis on;
caption = sprintf('Original Color Image, %s', baseFileName);
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
hp = impixelinfo(); % Set up status line to see values when you mouse over the image.
hold on;
plot(topRow, 'b-', 'LineWidth', 2);
Now that you have the top row you'll have to examine it to find the part of it that identifies the back, like where it starts and stops. Can you do that?
  5 Comments
Image Analyst
Image Analyst on 28 May 2018
Sure you can compare (your step 3) the actual shape (step 2) to the correct or preferred shape (step 1), but you still have to identify the parts of the plot that you want to use in the comparison. In other words, you still need to identify the back and exclude the head, even if you do plan on comparing with a reference/correct shape later in step 3. So you still need to flesh out the details of step 2 a little bit. And you need to define features of the back elements you extract since the number of those won't necessarily be the same number of elements as the reference curve. For example you need to coefficients of the polynomial or whatever.
cha bha
cha bha on 28 May 2018
Edited: cha bha on 28 May 2018
Ok i will try with that, Another thing was,I tried to track user given point through the video,I able to track manually given point,How can i track several point?
This was the code to track one point given using marker.
if true
videoFileReader = vision.VideoFileReader('deadlift.mp4');
videoPlayer = vision.VideoPlayer('Position',[1,10,1280,720]);
objectFrame = videoFileReader();
% objectRegion = [264,122,93,93];
%
figure;
imshow(objectFrame);
[neck_X,neck_Y]= ginput(1);
% imshow(pointImage);
% points = detectMinEigenFeatures(rgb2gray(objectFrame));
pointImage1 = insertMarker(objectFrame, [neck_X,neck_Y],'+','Color','white');
figure;
imshow(pointImage1);
title('Detected interest points');
tracker = vision.PointTracker('MaxBidirectionalError',1);
initialize(tracker,[neck_X,neck_Y],objectFrame);
while ~isDone(videoFileReader)
frame = videoFileReader();
[points,validity] = tracker(frame);
out = insertMarker(frame,points(validity, :),'+');
videoPlayer(out);
disp(points);
end
end
I need to add several point to this,How can i do it?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!