Two axes vs. Single with [ im , im2 ]

Hi I am making a GUI and comparing options of showing the videos inside.
I will be showing them side by side and wanted to try the two opstion mention above.
I would expect them to be running equally fast as I am plotting the same amount of pixels are the same, but the difference is huge.
Ofcourse cat is costing something to run, but when profilling I see a large increase in drawnow.
Is this simply because having two axes enables matlab to start plotting one while starting to read the other? or is there something about having to concat images that just takes longer due to how the code is interperted.
Hope someone has a bit more experience and could confirm my assumption or inform me about the cause, thank you in advance!
Code two axes:
while bVideoRunning
im = cellfun(@readFrame,VideoObjects,'UniformOutput',false);
imconcat = cat(2,im{1},im{2}) % I have also tried imconcat = [im{:}] but it is not faster the same with not using cellfun
set(hImage1, 'CData' ,imconcat);
drawnow
end
Code concat images:
while bVideoRunning
im = readFrame(VideoObjects);
set(hImage1, 'CData' ,im);
im2 = readFrame(VideoObjects2);
set(hImage2, 'CData' ,im2);
drawnow
end

5 Kommentare

The cellfun() might be the slow part.
Note:
imconcat = horzcat(im{1},im{2});
is potentially a hair faster.
Hi Walter, thank you for your fast reply!
I have tried also doing:
im = readFrame(VideoObjects);
im2 = readFrame(VideoObjects2);
imconcat = cat(2,im,im2)
set(hImage1, 'CData' ,imconcat);
drawnow
But it was not really much faster, I was still struggling with 1920x1080 at 25 FPS, I am achieving around 18 max.
Thanks, I will change try changing to horzcat also :)
Walter Roberson
Walter Roberson am 8 Feb. 2021
Experiment with using two hImage* on the same axes, but with different XData parameters at creation time. XData and YData determine where on the axes the data gets placed.
Caution: XData and YData are positions for centers of pixels.
Johan Svendsen
Johan Svendsen am 8 Feb. 2021
Amazing Walter! that worked, so would this indicate that is is because it can start plotting one then the other? or what is the cause of this performance difference?
Walter Roberson
Walter Roberson am 8 Feb. 2021
Unfortunately I have no useful speculation about that at the moment.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Images finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2020b

Gefragt:

am 8 Feb. 2021

Kommentiert:

am 8 Feb. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by