App Designer slow update imshow() in slider threshold

14 views (last 30 days)
Hello !
I am currently building an App to reproduce my image process for my research, learning by the same time how to use App designer.
One of the step of my image processing is to threshold the image. I use a slider to let the user change the value, put the value in an imbinarize() and update the image in the corresponding UIAxes. But my app is quite slow (4-5s to display the binarized image), I wonder if my code is really optimised (note: my images are 1920x2560-8bit gray images ).
I use 'CData' of the UIAxes instead of calling imshow as adviced in previous post about videodisplay but the time remains the same (4-5s to update).
I tried to use a logical test (>threshold) instead of imbinarize(), it didn't change the time. It works quicker with a smaller image ('coins.png') but when I execute this threshold process with my big images in a matlab script the imbinarize() and imshow() operations take less than 0.3s. Also when I simplify my app and remove all the other components used in the rest of the image process, it performs faster.
Do you have any suggestions that would explain why my app is so slow to update, or how I should deal with the many components of the app without loosing speed ? Or is my App just to heavy with all the components ?
I attached in a .zip the app and one of the image".tif' used. Most of the App components are not doing anything yet, I am coding the threshold part for now. To reproduce, just press button "load BF Image" and select the "image.tif" attached.
Many thanks for your help !
Romain
  1 Comment
Y.Yang
Y.Yang on 13 Oct 2020
Updating CData of imshow/imagesc handle in uifigure/uiaxes is much slower than in Figure/axes.
clear all;clc;
a=rand(1024,1024,100);
f = figure; % You can change to UIFIgure to compare the results
f.Renderer = 'opengl';
ax = axes('Parent',f);
im = imshow(a(:,:,1),'Parent',ax,'Border','tight','InitialMagnification','fit');
tic
for n=1:size(a,3)
im.CData = a(:,:,n);
drawnow;
end
toc
If the plot area is not 1920X1080px , you may plot the image with a more sparse way, im=imshow(data(1:8:end,1:8:end));
Or update the image result in a seperate window created by figure command which may boost the performance but not a pure appdesigner program.

Sign in to comment.

Answers (0)

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!