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
0 个评论
采纳的回答
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 个评论
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 Center 和 File Exchange 中查找有关 Data Exploration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!