dynamic images for temporal dithering

14 次查看(过去 30 天)
André
André 2024-3-8
回答: Tejas 2024-8-19,10:34
I am trying to test temporal dithering to increase the color depth of my monitor. I dont want to use third party software such as Psychotoolbox, MEX, or other external stuff.
Is there any way to create dynamic temporal images of short duration, like gifs, that can be ploted by MATLAB, without using infinite loops or other blocking routines? I don't want these loops to block my GUI runtime.
Does MATLAB support async programming? Is it a good idea to use it for this purpose? Any ideas?

回答(1 个)

Tejas
Tejas 2024-8-19,10:34
Hello André,
To create dynamic temporal images, use the Axes UI component to plot the images. Then use 'timer' function to execute a function at regular intervals, to update those images.
Follow the below-mentioned steps to create dynamic temporal images using App Designer:
  • Add an Axes component to the UI, which will be used to plot the images.
  • Create a private property named ‘Timer.
properties (Access = private)
Timer
end
  • Add a startupFcn callback for the app. This callback will define the properties of the ‘timer’ object and call the updateImage function at regular intervals.
function startupFcn(app)
app.Timer = timer('ExecutionMode', 'fixedRate', 'Period', 0.1, ...
'TimerFcn', @(~,~) updateImage(app));
start(app.Timer);
end
  • Add the updateImage function as a private method.
function updateImage(app, ~, ~)
imgSize = [100, 100, 3];
newImgData = rand(imgSize);
imagesc(app.UIAxes, newImgData);
axis(app.UIAxes, 'off');
end
  • Finally, add the UIFigureCloseRequest callback to the app to stop the timer when the app is closed.
function UIFigureCloseRequest(app, event)
stop(app.Timer);
delete(app.Timer);
delete(app)
end
Kindly refer to the following documentation to know more on 'timer' function:

Community Treasure Hunt

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

Start Hunting!

Translated by