fast sum 3D matrix, Mex file
Show older comments
Hello,
I would like to sum all pixels values of a 3D matrix in one dimension and put the final result in a 2D matrix. For example, the input is a 3D matrix: A(1280,1280,700). And the output is a 2D array: D(:,:) = A(:,:,1)+A(:,:,2)+A(:,:,3)+.....
As you can see in the mex file (test.c), the sum of all pixels is stored in a variable: pix. But while storing this variable into the array, the calculation time become very long: >40 sec... I don't understand why the writing into an array is taking so long. Is there a way to improve the Mex function in order to compute the algorithme faster?
Thank you for your answer.
Kind regards, Fouad
Accepted Answer
More Answers (0)
Categories
Find more on Programming 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!