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

3 次查看(过去 30 天)
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

采纳的回答

Sean de Wolski
Sean de Wolski 2011-6-16
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 个评论
Jon
Jon 2011-6-16
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 2011-6-16
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?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Exploration 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by