Displaying Histogram IN GUI AXES using imhist

7 次查看(过去 30 天)
I am trying to display the histogram of an image in a GUI using GUIDE. The Gui has two AXIS the first axis displays the image and the second Axis is meant to display the Histogram, however whenever i run the call back the histogram figure will appear correctly but not in the axis. I'm not sure if the handles.axes2 is in the right place, however i have tried it in all other logical (to my mind) places within the code. Any Advice would be very appreciated.
Code below
Many Thanks
Luke
a=imread('Im2.png');
agray=rgb2gray(a);
x=agray;
figure, imshow(x);
handles.axes2;
figure, imhist(x);

回答(2 个)

Sankarshan Bangaloree
I created a fcn from axes guide then i used this you can try this it worked for me
function axes3_CreateFcn(hObject, eventdata, handles)
I=imread('Im2.png');
I=rgb2gray(I);
imhist(I)
axes(handles.axes3);

Geoff Hayes
Geoff Hayes 2016-3-5
编辑:Geoff Hayes 2016-3-5
Luke - I am unsure about the line of code
handles.axes2;
What is the intent of this line? If you wish to set this to be the current axes, then you should do this as
axes(handles.axes2);
However, I don't know if that will be sufficient as I don't have the Image Processing Toolbox to verify.
If the above doesn't work, then see the documentation for imhist. There isn't an input parameter indicating the target axes upon which to draw the histogram, so you may have to draw it yourself using the output from imhist as
[counts,binLocations] = imhist(x);
stem(handles.axes2,binLocations,counts);

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by