dynamic images for temporal dithering

조회 수: 1 (최근 30일)
André
André 2024년 3월 8일
답변: Tejas 2024년 8월 19일
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?

채택된 답변

Tejas
Tejas 2024년 8월 19일
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:

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by