ginput not recognizing axes with origin in upper right-hand corner
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
PROBLEM SETUP: I am working on trying to analyze some image sets in a custom built GUI (using guide). It is my understanding that when I use an axes to display my image the coordinate system origin is in the upper left-hand corner. However, I was the origin being in the upper right-hand corner with the numbers decreasing as the coordinate system goes left to right. Setting XDir to reverse in guide (from my understanding) can change the coordinate system of the axes.
MY ISSUE: My issue is ginput still sees the origin being in the upper left-hand corner and not the upper right-hand corner. Note: I do not need the origin to be the traditional (0,0) but rather I need ginput coordinate values to decrease in value as I go from left to right and increase as I go from top to bottom. Also I know I could just do a subtraction with ginput in the x direction to get a reversed coordinate system but I would prefer to use a already built in function to simplify my life in the future.
Thank you in advanced for any advice you can provide me.
Jon
0 comentarios
Respuesta aceptada
Sean de Wolski
el 16 de Jun. de 2011
I would just write a quick wrapper function for ginput - you'll never even know!
%Call it with this
I = imread('cameraman.tif');
imshow(I);
[ii jj] = ginputij(I,2)
Here's a wrapper:
function [ii jj b] = ginputij(I,n)
%Function ginputij: ginput which returns matrix coordinates for upper right hand origin
%SCd 06/16/2011
%
%Inputs:
% -I: image
% -n: optional number of clicks
%
%Outputs:
% -ii: index rows of image selected
% -jj: index columns of image selected
% -b: button used
%
%See Also: ginput imshow
%
if nargin==1
n = 1;
elseif nargin~=2
error('1 or 2 input arguments expected');
end
[x y b] = ginput(n);
jj = size(I,2)-x;
ii = y;
end
Note: I;m using columns and rows instead of x/y swap them if you want...
2 comentarios
Sean de Wolski
el 16 de Jun. de 2011
With an image they're all integer values being returned from ginput so there shouldn't be any noticeable error. If we're talking about the same error?
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Exploration en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!