Pixel-wise median of sequence of cv::Mat's
<p>Note: I am NOT asking about Median Filter.</p>

<p>I have a sequence of images let us say:</p>

<pre><code>std::array&lt;cv::Mat,N&gt; sequence;
</code></pre>

<p>I want to blend all those images in one. This one image should satisfies:</p>

<p>Each pixel of the new image is the median of its corresponding pixels from the sequence. In other words:</p>

<pre><code>Result(i,j)=median(sequence[0](i,j), sequence[1](i,j), ..., sequence[N](i,j));
</code></pre>

<p>Is there built-in function for doing that? What would be the fastest way?</p>

<p>What I tried till now: To iterate over each pixel from all the sequence and sort then take the median then store it in the result. However, it is so overkill.</p>