0

I have a canvas and an image on it and I am trying to apply a blur effect on it.I know the form of the convolution matrix for blurring, but I do not know how to make the mathematical operations with it and with the pixels. Could someone help, please?

convM=[1/9, 1/9, 1/9,1/9, 1/9, 1/9,1/9, 1/9, 1/9];
var imgE = ctx.getImageData(0,0,300,200);
var pix = imgE.data;
for (var i = 0;i < pix.length; i += 4) {
       //for each color channel             
}
imgE.data=pix;
ctx.putImageData(imgE, 0,0);
KARTHIKEYAN.A
  • 18,210
  • 6
  • 124
  • 133
Andreea
  • 149
  • 1
  • 3
  • 10
  • Can you share the full code that you are working with ? – Karan Dec 29 '17 at 06:33
  • Sorry, I know that it is recommended to share the full code, but this it just a small part of a large project and I cannot share the code on the internet. – Andreea Dec 29 '17 at 06:43
  • [Here's one way](https://stackoverflow.com/a/19235791/1693593) to apply convolutions, just replace the convolution matrix with one for blur (instead of sharpen as in the link). –  Dec 29 '17 at 06:44
  • It's not recommended to share the full code: [MVCE](https://stackoverflow.com/help/mcve) – Psi Dec 29 '17 at 07:32

0 Answers0