How do I compute coordinate of an image in Matlab?
조회 수: 27 (최근 30일)
이전 댓글 표시
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!
댓글 수: 0
채택된 답변
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
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
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개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!