dynamic images for temporal dithering

7 views (last 30 days)
André
André on 8 Mar 2024
Answered: Tejas on 19 Aug 2024
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?

Accepted Answer

Tejas
Tejas on 19 Aug 2024
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:

More Answers (0)

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!