imshow and GUI axis handles

조회 수: 123 (최근 30일)
Paolo
Paolo 2013년 7월 12일
편집: Vivek Kumar Singh 2021년 8월 4일
I have to display an image in a GUI figure. In the figure there are two axes.
How can I tell
imshow
to display the image in the axis I want? With
plot
I could use
plot(handles.axis1,image)
but this doesn't work for imshow (<http://www.mathworks.it/it/help/images/ref/imshow.html>)! The code
imshow(handles.axis1,image)
is not allowed,
imshow
doesn't accept axis handles.
Any suggestion to solve this issue?

채택된 답변

Image Analyst
Image Analyst 2013년 7월 12일
You can specify the axes in the call to imshow with the 'Parent' option:
imshow(yourImage, 'Parent', handles.axesImage);
or you can specify it with the axes function in advance of calling imshow():
axes(handles.axesImage);
imshow(yourImage);
  댓글 수: 2
Victor Carvalho
Victor Carvalho 2015년 8월 20일
It's funny that only the first option worked for my GUI. Thank you!
Image Analyst
Image Analyst 2015년 8월 20일
I would be stunned and shocked if my second option did not also work. The function axes() switches the current axes to what you specify, and imshow() with no parent option will display in the current axes.

댓글을 달려면 로그인하십시오.

추가 답변 (5개)

Dishant Arora
Dishant Arora 2013년 7월 12일
axes(handles.axis1);
imshow(YourImage)
And you can get handles to different axis using findobj:
hAxes = finobj(gcf, 'type' ,'axes');
  댓글 수: 4
Ahmad Mahmood
Ahmad Mahmood 2018년 6월 29일
편집: Ahmad Mahmood 2018년 6월 29일
Hi! I have an image 649x487, and I have two vectors that match in length of the x dim and y dim. I was want to use these vectors as the axes, and not the pixel dimension the image comes with. Do you know how I could do that? I also want to view these axes using imshow(). Thank you for your help!
Image Analyst
Image Analyst 2018년 6월 29일
Use 'xdata' and 'ydata'.
imshow(yourImage, 'XData', x, 'YData', y);

댓글을 달려면 로그인하십시오.


kousar majeed
kousar majeed 2019년 6월 16일
axes(handles.axesImage);
imshow('Lena.jpg');
i just want to show display image in gui axes but it is not working in push button when i call it ? need help
  댓글 수: 1
Vivek Kumar Singh
Vivek Kumar Singh 2021년 8월 4일
편집: Vivek Kumar Singh 2021년 8월 4일
function UPLOAD_Callback(hObject, eventdata, handles)
% hObject handle to UPLOAD (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[file,path]=uigetfile('*.*','Select image');
loc=strcat(path,file);
pic=imread(loc);
axes(handles.AXES1);
imshow(pic);
Something similar works for me as i am uploading image via a callback from button whose tag is UPLOAD, and my axes name is AXES1

댓글을 달려면 로그인하십시오.


kousar majeed
kousar majeed 2019년 6월 16일
% --- 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)
axes(handles.axesImage);
imshow('Lena.jpg');
identify my mistake??????
  댓글 수: 1
Image Analyst
Image Analyst 2019년 6월 16일
Should be okay as long as lena.jpg is in your search path or current folder.
Explain what "not working" means to you? Is there an error message?

댓글을 달려면 로그인하십시오.


kousar majeed
kousar majeed 2019년 6월 16일
1) display my simple image using gui
now i want to learn more
1) how i can load one by one frame from folder of frame: code
2) then display it into GUI axes
waiting for ur answer
  댓글 수: 1
Image Analyst
Image Analyst 2019년 6월 16일
If you can't get it working, post what you have and say what you want to do or measure in your images.
But do it in your own, new post instead of in this 6 year old answer to someone else.

댓글을 달려면 로그인하십시오.


Afaq Khan
Afaq Khan 2021년 5월 16일
what does it mean by adding term 'parent' in imshow..?

Community Treasure Hunt

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

Start Hunting!

Translated by