Keep a figure full screen while looping

5 vues (au cours des 30 derniers jours)
BMEenthusiast
BMEenthusiast le 24 Juil 2019
Réponse apportée : Rik le 24 Juil 2019
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 commentaires
Rik
Rik le 24 Juil 2019
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 le 24 Juil 2019
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

Connectez-vous pour commenter.

Réponses (1)

Rik
Rik le 24 Juil 2019
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).

Catégories

En savoir plus sur Display Image dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by