Question

I'm trying to use getpts to get the location of the selected points by the user.

I used it as follows:

[X,Y] = getpts(imread('xyz.jpg'));

But, got the following error:

Error using getpts (line 46)
First argument is not a valid handle.

Error in program (line 7)
[X,Y] = getpts(imread('xyz.jpg'));

Why is that?

Thanks.

Était-ce utile?

La solution

getpts needs a handle to either a figure or an axes, not a matrix as given by imread.

The simple solution is to display the image, then input either gca or gcf to getpts. Or you can manage handles on your own, but I don't think you wan't to do that.

Or to put it on one line with imshow:

[X,Y] = getpts(get(imshow('xyz.jpg'),'Parent'));
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top