필터 지우기
필터 지우기

Plotting on background image of GUI

조회 수: 5 (최근 30일)
Mohammed Aatif Shahab
Mohammed Aatif Shahab 2021년 2월 6일
댓글: Mohammed Aatif Shahab 2021년 2월 9일
I have to plot some data on an image. When I am doing this with GUI after loading image, the image disapperas.
Here is my code.
global varTrend
f = figure('Visible','on','Name','',...
'Menubar','none','Toolbar','none', 'Units', 'points','NumberTitle','off',...
'Position',[0,0,1366,768],'Resize','on','color',[127 127 127]./255); % window
GazePanel = uipanel('Parent',f,'HandleVisibility','callback','Units','normalized' ...
,'Position',[0 0 1 1],'BackgroundColor',[127 127 127]./255); % Panel within the window
varTrend = axes('Parent',GazePanel,'HandleVisibility','callback', ...
'NextPlot','replacechildren','Units','points','Position', ...
[0,0,1366,768],'FontSize',8,'Color',[127 127 127]./255); % Axis within the window
imshow('D:\GUI.png','Parent',varTrend); % show the image
% This code is doing plotting on varTrend axis
count = 1;
for i=1:length(x_coordinate(1:300))
for j = 1:length(AOI_each)
if (x_coordinate(i)>=AOI_each(j,1)&&x_coordinate(i)<=AOI_each(j,2)&& ...
y_coordinate(i)>=AOI_each(j,3)&&y_coordinate(i)<=AOI_each(j,4));
AOI(i)=j;
if i ~=1
if AOI(i)~=0
saccade = i -1;
if AOI(i-1) ==0
idx = max(find(AOI(1:i) ~=0));
saccade = idx;
end
% giving weightage to each AOI
if AOI(i-1) == AOI(i)
count = count + 1;
scatter(varTrend,AOI_centroid(j,1),AOI_centroid(j,2),count*20,'filled','r')
hold on
end
if AOI(i-1) ~= AOI(i)
count = 1;
scatter(AOI_centroid(j,1),AOI_centroid(j,2),600,'filled','r')
hold on
plot(varTrend,[AOI_centroid(AOI(saccade),1) AOI_centroid(AOI(i),1)], ...
[AOI_centroid(AOI(saccade),2) AOI_centroid(AOI(i),2)],'-r','LineWidth',2)
end
xlim([0 1920])
ylim([0 1080])
pause(0.0001)%drawnow
hold on
else
break;
end
end
end
end
end

답변 (1개)

Image Analyst
Image Analyst 2021년 2월 6일
Of course we can't run your image for several reasons but I'm guessing is that you called scatter() or plot() before "hold on" was applied. Try calling hold on immediately after imshow():
imshow('D:\GUI.png', [], 'Parent',varTrend); % Show the image
hold on;
  댓글 수: 6
Image Analyst
Image Analyst 2021년 2월 8일
What is the gaze panel for? Why not just simply call imshow, hold on, then plot or scatter? Why are you doing all kinds of special, fancy stuff wtih the controls?
Mohammed Aatif Shahab
Mohammed Aatif Shahab 2021년 2월 9일
Ok Thanks a lot for continuous guidance. I will remove the fancy stuffs.

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

Community Treasure Hunt

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

Start Hunting!

Translated by