Jump to content
  • Advertisement
Sign in to follow this  
Endemoniada

Convolution (Box) Filters ?

This topic is 4759 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, I'm starting to mess around with box filters, I programmed it myself so I'm not using any library. I basically get at the image bytes and run each pixel through my filter. Let's say I'm just using the surrounding pixels, for a 3x3 box. What do I do with the corners and the edges ? Some tutorials say to not process them but to me that doesn't seem good. Do I make a special case and adjust the weights ? It's confusing, what should I do ? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
A very good question! One common solution is to pretend that there are pixels beyond the edge of the image and to use those when doing your calculations, as if they were pixels of the actual image. The problem is: what colour do those extra pixels have? There are several different solutions to this:

1) They are all black
2) Each one has the same colour as the adjacent edge pixel (probably more useful)
3) There are some other solutions, which I don't remember off the top of my head.

Which particular approach you take (and whether you want to process the edge pixels at all) probably depends on what exactly you want to achieve with your filters. There is a lot about this on the internet, so it's worth googling around.
Good luck!

Share this post


Link to post
Share on other sites
Another trick is to pretend the pixels beyond the edge are actually on the opposite edge - wrapping around the image. This should would well for images that are meant to be tileable, but like Deniz said it depends on what you want to use the result for.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
One approach I was planning to use is to reduce the size of the filter at the edges, so pixels outside the screen don't contribute. If you use a 3x3 filter, and one row is outside the screen, divide the final result by 6 instead of 9.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!