ginput not recognizing axes with origin in upper right-hand corner

3 views (last 30 days)
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

Accepted Answer

Sean de Wolski
Sean de Wolski on 16 Jun 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 Comments
Jon
Jon on 16 Jun 2011
True this is easier but I was avoiding it because I wanted to prevent introducing a round off error. But then again when I think about it the round off error that would be introduce is negligible to the total error.
Thank you for your input.
Sean de Wolski
Sean de Wolski on 16 Jun 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?

Sign in to comment.

More Answers (0)

Categories

Find more on Visual Exploration in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!