필터 지우기
필터 지우기

Loading a Histogram in a GUI with data from another Function

조회 수: 1 (최근 30일)
Luke Dineen-Woolnough
Luke Dineen-Woolnough 2016년 3월 3일
답변: Image Analyst 2016년 3월 5일
I'm looking at using a push-button in a GUI to load up a histogram of an image that is already loaded into the GUI. I don't think I've got the handles quite right, can anyone suggest what im doing wrong?
Code below
Many Thanks
Luke
%%CallBack
set(h.buttonone, 'callback', {@addaxes1, h});
set(h.buttontwo, 'callback', {@applywindow, h});
set(h.buttonthree, 'callback', {@Hg, Im2, h});
then in seperate function (@Hg)
function Hg = Hg(hObject, eventdata, h);
subplot(1, 2, 2);
y = histogram(Im2), h.axes2;
I keep getting an error saying
"Error using Hg
Too many input arguments"
This error refers to the top line of function Hg.

답변 (2개)

Geoff Hayes
Geoff Hayes 2016년 3월 5일
Luke - I wonder if the problem is with the signature of your function
function Hg = Hg(hObject, eventdata, h);
You have named this function Hg but are also trying to return a parameter named Hg. What is the intent? How is this output variable used? Is it even necessary?
Also, please clarify when the above error occurs. (i.e. in response to what action by the user.)

Image Analyst
Image Analyst 2016년 3월 5일
Try this:
function histObject = Hg(yourImage, handlesStructure);
subplot(1, 2, 2);
histObject = histogram(Im2);
% Switch current axes to axes2:
axes(handlesStructure.axes2);

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by