Borrar filtros
Borrar filtros

Using getpts to get selected points

25 visualizaciones (últimos 30 días)
med-sweng
med-sweng el 18 de Abr. de 2014
Respondida: Geoff Hayes el 19 de Abr. de 2014
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.

Respuestas (1)

Geoff Hayes
Geoff Hayes el 19 de Abr. de 2014
Hi med-sweng,
According to the documentation for getpts, the valid inputs to this function are a figure (fig), the axes specified by the handle ax, or the current figure handle (gcf). In your example, you are passing the result of imread('xyz.jpg') which is a matrix containing the image data and so is not a "valid handle" as per the error message. You may need to do something like the following instead:
[I] = imread('xyz.jpg'); % read the image into the matrix
imshow(I); % display the image
[x,y] = getpts; % get the points from the current image
You don't need to pass anything to getpts as the current figure handle will be used. (An alternative may be to do [x,y] = getpts(imshow(I)) ;
Hope that this helps!
Geoff

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by