I have a 3x3 matrix, for example:
Now i want to implement the equation
where q5 is the centre pixel
q4,46 are neighbouring pixels
d= q1 q2 q3
q4 q5 q6
q7 q8 q9
No products are associated with this question.
Hard to tell. You might be asking for
oldMatrix = double(ImageMatrix); NewMatrix = ( oldMatrix(:,1:end-1) + oldMatrix(:,2:end) ) ./ 2;
But perhaps your "d" matrix is trying to talk about weighting the pixel values ? If so then let w1 be the weight for what you showed as d(q4,q5), and let w2 be the weight for what you showe as d(q5,q6), and then
NewMatrix = ( w1 .* oldMatrix(:,1:end-1) + w2 .* oldMatrix(:,2:end) ) ./ 2;
By chance do you mean just convolution with a [1 2 1]/4 kernel, where you take the average of the left pair of pixels and the right pair of pixels? If so, you'd need to extract each color plane first and then use conv2() to get the output image one color plane at a time.
Play games and win prizes!Learn more