Excessive median processing time

2 ビュー (過去 30 日間)
Sean
Sean 2013 年 2 月 1 日
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

回答 (1 件)

the cyclist
the cyclist 2013 年 2 月 2 日
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.

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by