Excessive median processing time
3 views (last 30 days)
Show older comments
I have found that taking the median with respect to time of a group of image frames can take excessively long and is dependent on how the data is formatted as shown below:
>> tic;median(single(ones([1080 1920 3 30])),4);toc;
Elapsed time is 89.073999 seconds.
>> tic;median(single(ones([1080*1920*3 30])),4);toc;
Elapsed time is 1.509120 seconds.
I'm wondering both:
a) why is the time so different between these two cases?
b) is there any way to get around dumping everything into a massive single dimension like this if I want it to process in a reasonable period of time (because it would be so easy to make mistakes in reorganizing data back and forth like this)
Does anyone have any insight into this behavior and how to get around it?
Thanks in advance, Sean
0 Comments
Answers (1)
the cyclist
on 2 Feb 2013
First off, I assume that in your second case, you meant to take the median along dimension 2. Otherwise, you don't get equivalent results.
I think you will still get very different timing results, based on a quick peek inside the median function, using
>> edit median
I frankly did not dig deeply to get an understanding, but there is very clearly code (lines 93-101) that takes advantage of vectorization for 2-dimensional arrays.
0 Comments
See Also
Categories
Find more on Matrices and Arrays 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!