How can i track points in two images?
16 views (last 30 days)
Show older comments
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
Accepted Answer
More Answers (1)
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
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.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!