How do I compute coordinate of an image in Matlab?

조회 수: 39 (최근 30일)
Alexander Killam
Alexander Killam 2014년 2월 10일
편집: Thomas Seers 2014년 2월 10일
I have an image. Lets say I call it bug...(It is an image of a small red bug with a white background). I want to be able to find the coordinates of where that bug is on matlab. I would like to be able to do this so that if I had another image in a different location I could track where the bug is in the new image. I am trying to learn matlab on my own so any in depth explanation would be greatly appreciated. Thank you very much!

채택된 답변

Thomas Seers
Thomas Seers 2014년 2월 10일
편집: Thomas Seers 2014년 2월 10일
It really depends upon what you want. If you only want to track a single point, or a few points within your image series this can be done very easily with the image processing toolbox function impixel:
The following script will let you open up a series of JPEG files, and allow you to interactively identify single or multiple points of interest in each image. The image coordinates are output to a cell matching the order of the input images, coords.
% Open all images using dialogue box
[FileName,PathName] = uigetfile('.JPG', 'select image files','multiselect', 'on');
images = transpose(FileName);
% open each image and interactively define the point of interest using impixel
% store output in a cell (coords)
coords = cell(size(images,1),1);
for i = 1:size(images)
im = imread(strcat(PathName, images{i}));
[xi,yi,P] = impixel(im);
coords{i} = horzcat(xi,yi); % store xy coordinates from each point of interest
end
You may need to be more specific if you want something more sophisticated (i.e. to track all non white pixels.
Thomas
  댓글 수: 3
Thomas Seers
Thomas Seers 2014년 2월 10일
You need to define what constitutes a 'point'. What we know is a point intuitively is by no means straight forward to define programmatically between an image series of the same object. For this you may need to look at computer vision feature detection algorithms such as Rob Lowe's scale invariant feature transform (SIFT).
Thomas Seers
Thomas Seers 2014년 2월 10일
편집: Thomas Seers 2014년 2월 10일
Another route might be compute the barycentre of the non white pixels (i.e. identify each pixel where
im(:,:,1) < 255 || im(:,:,2) < 255 || im(:,:,3) < 255;
or set some other threshold and find their centre of mass). You would be including some of that fuzz around the bug into the calculation though.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Geometric Transformation and Image Registration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by