Diagonal Profile over matrix / image

5 views (last 30 days)
fransec
fransec on 11 Jun 2020
Hello everydoby.
I have a series matrix / images of named TI, developing over time of size 501x501 pixel.
For my scientific purposes, I created a processing in which I transform each image in a row or in a column long 1x501 or 501x1, that I call horizontal or vertical profiles, with a loop where I sum all the horizontal or vertical values long 501x1 or 1x500 and I lock all these arrays in two final matrix sized 501x nimages, profileNS and profileWE.
k=1
for i=1:nimages
load(TI(i)) % load the TI matrix corresponding to each iteration over time
TI_current=TI;
profileNS(:,k)=(nansum(TI_current'))'; % Profile North-South
profileWE(:,k)=(nansum(TI_current)); % Profile West-East
k=k+1; % counting
end
This process is made just making sum on horizontal and vertical column/rows, like a scanning moving from top to down and from left to right.
Now. I would like to recreate this processing not just moving horizontally or vertically, but diagonally. The problem is that I don't need a simple profile along a line, that I could make with the command improfile over a diagonal line, but I need to build cumulative sum arrays in order to have a matrix at the end.
But If apply a sum over diagonal direction in my matrix, I will sum different number of pixels. The central diagonal will be of 501 pixels, but the others diagonal, shifted to the top or to the bottom of the image, will be the result of fewer pixels.
So, anybody has some ideas how to construct something like a cumualtive sum profile matrix but made by diagonal scanning?
Thank you so much!

Answers (0)

Categories

Find more on Operating on Diagonal Matrices 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!