I have a grayscale matrix (implemented as a simple array) to be shown on a display:line 1: | a | b | c |line 2: | d | e | f |a-f are grayscale values. This pattern has to be shifted by a variable percentage to the left or to the right.What I currently do is an easy approach:For example, shift 20% to left, so:a_new = a * (1 - 0.2) + b * 0.2b_new = b * (1 - 0.2) + c * 0.2c_new = c * (1 - 0.2) + 0and so on. That is, I have a loop over all elements.With only six elements I don't care, but in fact the matrix is much bigger.Of course, the factor (1 - 0.2) can be reused, but I wonder if there is a smarter way of calculating the resulting (shifted) matrix?
How to do image shifting faster?
algorithms;array