How can we perform cumulative sums along a particular directions in matrices?
2 views (last 30 days)
Show older comments
Hi all,
I'm actually trying to perform cumulative sums along arbitrary directions in images. For sure a simple sum can be done with the radon() function, however I need to keep track of an integral, thus requiring a cumsum(). I've tried to use imrotate() and then cumsum() but initial and final images don't have the same dimensions anymore, causing another problem.
Any help would be really appreciated!
Regards,
Simon
1 Comment
the cyclist
on 20 Jun 2013
It might be helpful to give a small example or two of inputs and expected outputs.
Accepted Answer
Image Analyst
on 20 Jun 2013
I pretty sure there's nothing built in to MATLAB or the Image Processing Toolbox to do that. You'd have to program it up yourself. Sorry, but it's just such a unique requirement that there's no code yet to do that as far as I know. It can be done though. You might find improfile() helpful as you scan across, at one pixel spacings or whatever you require, getting profiles and calling cumsum().
2 Comments
More Answers (1)
the cyclist
on 20 Jun 2013
Direct from the documentation:
B = cumsum(A,dim) returns the cumulative sum of the elements along dimension dim.
Does that help?
So,
A = magic(5);
B_down = cumsum(A,1); % Cumulative sum down columns (the default)
B_across = cumsum(A,2); % Cumulative sum across the rows
See Also
Categories
Find more on Graphics Performance 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!