필터 지우기
필터 지우기

imshow inhibits gui from running minimized

조회 수: 2 (최근 30일)
Max
Max 2014년 3월 21일
댓글: Sean de Wolski 2014년 6월 9일
I have an question concerning the imshow command for GUI. I am processing a lot images and wanted to display the current image using the axes feature. It works fine, only that the whole window gets refreshed everytime a new image is processed. Thats why i can't minimize the window which stays always in the foreground.
What could i do to avoid this?
Code looks like this: It reads some images, does the processing and safes them afterwards.
function execute_Callback(hObject, eventdata, handles)
global filenames
global path
for i=1:length(filenames)
nfilename2=[path,filenames{i}];
pic = imread(nfilename2);
axes(handles.axes1);
imshow(pic);
end
Thank you!

채택된 답변

Sean de Wolski
Sean de Wolski 2014년 3월 21일
Specify the parent for imshow to plot to inside of imshow, rather than as axes(handles.axes1)
ax = gca;
imshow('cameraman.tif')
Hide figure
imshow('peppers.png','parent',ax)

추가 답변 (1개)

Erik
Erik 2014년 6월 5일
The solution from Sean does not seem to work in a gui.
  • Suppose we create a guide with only a single axes 'axes1'.
  • In the OpeningFnc we create, initialize and start a timer object to trigger every 0.1 sec.
  • In the timer callback function we call :
imshow('peppers.png','parent',handles.axes1);
If it runs, then the gui window get on top with every call to imshow. Not so nice for live image analysis applications. Therefor I prefere therefor to use simple image instead of imshow and change the axis to off.
function imshowguitest_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
handles.timer = timer;
handles.timer.StartDelay = 0.1;
handles.timer.Period = 0.1;
handles.timer.ExecutionMode = 'fixedSpacing';
handles.timer.TimerFcn = {@timer_Callback, hObject};
start(handles.timer);
guidata(hObject, handles);
function figure1_CloseRequestFcn(hObject, eventdata, handles)
stop(handles.timer);
delete(hObject);
function timer_Callback(~, ~,hObject)
handles = guidata(hObject);
imshow('peppers.png','parent',handles.axes1);
% a = imread('peppers.png');
% image(a,'parent',handles.axes1);
% axis(handles.axes1,'off');
  댓글 수: 1
Sean de Wolski
Sean de Wolski 2014년 6월 9일
For this I would take a different approach. Instead of rebuilding the image on each iteration, just update its color data ( 'CData' ). See my example here:
hImage = imshow(cat(3,ones(200,400),zeros(200,400,2)));
T = timer('Period',1,'TasksToExecute',10,...
'Timerfcn',@(~,~)set(hImage,'CData',circshift(get(hImage,'CData'),[0 0 1])),...
'StartDelay',1,'ExecutionMode','FixedRate');
start(T);
Full link:

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

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by