tags:

views:

276

answers:

3

I have a question about the values returned by getPosition. Below is my code. It lets the user set 10 points on a given image:

figure ,imshow(im);
colorArray=['y','m','c','r','g','b','w','k','y','m','c'];
pointArray = cell(1,10);
% Construct boundary constraint function
fcn = makeConstrainToRectFcn('impoint',get(gca,'XLim'),get(gca,'YLim'));
for i = 1:10
    p = impoint(gca);
    % Enforce boundary constraint function using setPositionConstraintFcn
    setPositionConstraintFcn(p,fcn);
    setColor(p,colorArray(1,i));
    pointArray{i}=p;
    getPosition(p)
end

When I start to set points on the image I get results like [675.000 538.000], which means that the x part of the coordinate is 675 and the y part is 538, right? This is what the MATLAB documentation says, but since the image is 576*120 (as displayed in the window) this is not logical.

It seemed to me like, somehow, getPosition returns the y coordinate first. I need some clarification on this.

Thanks for help

A: 

Your code uses the Image Processing Toolbox, which I don't have, so this is speculation. The coordinate system is probably set to the figure window (or maybe even the screen), not the image.

To test this, try clicking points outside the image to see if you can find the origin.

Richie Cotton
A: 

I just tried running your code in MATLAB 7.8.0 (R2009a) and had no problems with image sizes of either 576-by-120 or 120-by-576 (I was unsure which orientation you were using). If I left click inside the image, it places a new movable point. It did not allow me to place any points outside the image.

One small bug I found was that if you left-click in the image, then drag the mouse pointer outside the image while still holding the left button down, it will place the movable point outside the image and won't display it, displaying a set of coordinates that are not clipped to the axes rectangle.

I'm not sure of what could be your problem. Perhaps it's a bug with whatever MATLAB version you are using. I would suggest either restarting MATLAB, or clearing all variables from the workspace (except for the image data im).

gnovice
A: 

Might be worth checking to see which renderer you are using (Painter or OpenGL), a colleague showed me some wierd behaviour with point picking when using the OpenGL renderer which went away when using the Painter renderer.

Ian Hopkinson