Keep a figure full screen while looping

조회 수: 7 (최근 30일)
BMEenthusiast
BMEenthusiast 2019년 7월 24일
답변: Rik 2019년 7월 24일
I am currently working on a simple script where i have a figure with a solid color for an image, but it is a loop. every time it loops the image loses its color (like as its red, the more that time goes by the darker it gets until it is completely black.). However I want to keep the image in a full screen perspective. I found possible functions but for looping it doesn't work as it simply causes the image from it being maximized to its normal size, then back to maximized. I don't want it to continue doing that at all. is there a solution around this?
  댓글 수: 2
Rik
Rik 2019년 7월 24일
You are probably using imshow, which is a really high level function. You are probably better off using the image function or directly setting the CData property.
Without knowing some of your code it is difficult to tell.
BMEenthusiast
BMEenthusiast 2019년 7월 24일
oh yea I am using imshow. here is the current script that I have, however i removed the full screen functions since I have already determined that they aren't helping me as much.
clc;close all; clear
img=zeros(1000,1000,3); %initialize
color = 1;
img(:,:,1) = color;
figure(1), imshow(img)
%as it loops it will lose its color all the way until it reaches
%completely black
while color > -0.025
img(:,:,1)=color; %Red
color = color - 0.025;
figure(1)
imshow(img)
pause(0.1)
end

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

답변 (1개)

Rik
Rik 2019년 7월 24일
Store the output of imshow in a variable (it is a handle to the image object).
Then inside the loop only change the CData property with the set function. The calls to figure and imshow may both cause issues and are slowing your code needlessly.
Also, your first line of code is largely unnecessary. You're not outputting anything to the command window, so clc is not needed. Close all is not really needed either, because you're opening a specific numbered figure (use clf if you want to clear the contents of a figure). And clear should only be used during debugging (use functions to keep your workspace clean).

카테고리

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

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by