The task is to extract stable background out of the video, the idea is to choose n random frames from the video and take median for each pixel. I was doing this task in python using numpy
medianFrame = np.median(frames, axis=0).astype(dtype=np.uint8)
But now i need to perform the same task in C++. I have tried the naive way of splitting channels and going through rows*cols number of pixels for n frames to calculate the median frame but its not efficient at all and takes way more time than what np.median was taking. I also try to use xtensor for performing the task but wasn`t able to worlk with it. Any suggestions or direction about how to approach this task would greatly help me, Thanks!