Not Enough Input Arguments
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello! I want to click in a axes image and find out the x and y position of the clicked position. I want making 3 click. And using it coordinates draw a circle. How I can do it? I trust makes first click coordinates...But I have a problem with recording coordinates in static text. Can you help me?
function varargout = demoomimageclick(varargin)
% DEMOOMIMAGECLICK MATLAB code for demoomimageclick.fig
% DEMOOMIMAGECLICK, by itself, creates a new DEMOOMIMAGECLICK or raises the existing
% singleton*.
%
% H = DEMOOMIMAGECLICK returns the handle to a new DEMOOMIMAGECLICK or the handle to
% the existing singleton*.
%
% DEMOOMIMAGECLICK('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in DEMOOMIMAGECLICK.M with the given input arguments.
%
% DEMOOMIMAGECLICK('Property','Value',...) creates a new DEMOOMIMAGECLICK or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before demoomimageclick_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to demoomimageclick_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help demoomimageclick
% Last Modified by GUIDE v2.5 24-Jun-2016 14:56:09
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @demoomimageclick_OpeningFcn, ...
'gui_OutputFcn', @demoomimageclick_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before demoomimageclick is made visible.
function demoomimageclick_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to demoomimageclick (see VARARGIN)
% Choose default command line output for demoomimageclick
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes demoomimageclick wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = demoomimageclick_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[FileName, PathName]=uigetfile('*.bmp; *.jpg; *.gif', 'Open File');
if FileName~=0
rgb=imread(strcat(PathName, FileName));
end;
h=rgb2gray(rgb);
handles.imageHandle=imshow(h, [], 'parent', handles.axes1);
set(handles.imageHandle, 'ButtonDownFcn', {@ImageClickCallback, handles});
guidata(hobject, handles);
function ImageClickCallback (objectHandle, eventData, handles_old, handles)
handles_lastUpdated=guidata(handles_old.axes1)
p=get(handles_lastUpdated.axes1,'CurrentPoint');
x=floor(p(1,1));
y=floor(p(1,2));
handles_lastUpdated.x=x;
handles_lastUpdated.y=y;
guidata(handles_lastUpdated.axes1, handles_lastUpdated)
set(handles.text4, 'String', num2str(handles_lastUpdated.x));
set(handles.text5, 'String', num2str(handles_lastUpdated.y));
Error which I have in 2 last line:
Error using demoomimageclick>ImageClickCallback Not enough input arguments.
Error while evaluating Image ButtonDownFcn
Pleas, help me...
0 comentarios
Respuestas (1)
Jan
el 27 de Jun. de 2016
The function is defined as:
function ImageClickCallback (objectHandle, eventData, handles_old, handles)
and called by:
set(handles.imageHandle, 'ButtonDownFcn', {@ImageClickCallback, handles});
The cell is converted to
ImageClickCallback(ObjectH, EventData, handles)
So what is "handles_old"? It is missing in the call or why does "handles" occur in the argument list?
1 comentario
Ver también
Categorías
Más información sobre Graphics Object Properties 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!