0

I have a side project where I want to blur an image in C#. My idea is to use Bitmap to divide an image into red, blue and green arrays.

My next step is to make a 3x3 matrix and take the outer blocks of the array and place the average of the sum into the middle block.

Example place the average of the Z's and place it into the X value for each of the arrays of the RGB. The 3x3 would look like this:

ZZZ
ZXZ
ZZZ

Any help or comments would be much appreciated.

Fabian
  • 650
  • 2
  • 9
  • 21
FSmith94
  • 13
  • 1
  • Huh? Where do the separate arrays come into this? Are you trying to blur a single colour channel? – ProgrammingLlama Apr 19 '18 at 12:21
  • yes I'm tying to blur a single colour channal. Didn't got to that word :) – FSmith94 Apr 19 '18 at 12:27
  • The easiest (and slowest) way might be to use the `.GetPixel()` and `.SetPixel()` methods of the `Bitmap` object. Alternatively, you could take a look at [this](https://stackoverflow.com/questions/33562053/replace-color-of-a-image-using-lockbits) – ProgrammingLlama Apr 19 '18 at 12:31
  • Thanks a lot, I found that link very helpful! – FSmith94 Apr 19 '18 at 13:02
  • [This solution](https://stackoverflow.com/a/49859493/395685) may be interesting too. From the code there, the only remaining step is to fill the retrieved R, G and B values into their own arrays. and then process them. You can use a copy of the same loop to write them back into the main array. – Nyerguds Apr 20 '18 at 08:48

0 Answers0