Did you know this (from the help): "numberOfElements = length(array) finds the number of elements along the largest dimension of an array. " So "for i = 1 :length(TS)" might not be doing what you think it does. Better to use
[rows columns] = size(TS);
for k = 1 : column
By the way, don't use i (the imaginary variable) as a loop index.
And I don't see what's "Quartile" about it. You're going down each column one element at a time, calculating the median from the top row to the current row, then getting secondary medians of elements above, and below, the overall median. What about this is doing anything with quarters?
I don't see how this could be vectorized because the length of the strip that you're processing changes each time you move down a pixel. It's 1 the first time through, 2 long the second time through, 3 long the third time through, etc. So, of course, that explains why it takes longer with each iteration of i.
What effect does this have on the data anyway? What's its purpose?
Best Answer