[Math] How to apply a Gaussian Blur (low-pass filter) to an image made up from a set of points

image processingsignal processing

I have an image encoded in the form of a list of points, like so:

335.0 2743.0 
335.0 2754.0 
325.0 2754.0 
304.0 2743.0 
304.0 2733.0 
283.0 2723.0 
273.0 2702.0 
273.0 2691.0 
273.0 2681.0 
273.0 2670.0 
283.0 2670.0 
294.0 2670.0 
304.0 2670.0 
325.0 2670.0 
335.0 2681.0 
346.0 2702.0 
346.0 2712.0 
356.0 2723.0 
346.0 2733.0 
346.0 2743.0 
346.0 2733.0 
346.0 2723.0 
356.0 2702.0 
356.0 2670.0 
356.0 2660.0 
367.0 2660.0 

There is a line drawn between each point to make the image – if you sketch the points above (I'd advise doing it programatically) you'll see a lower case 'a'. This is part of a project regarding online character recognition. I am currently investigating the effects of several pre-processing techniques that can be applied to such a recognition system, and one technique that many of the papers that I have read apply is to 'smooth' the image, usually via a Gaussian blur. Unfortunately, they all proclaim it as "easy", and therefore they neglect to mention how one goes about doing so.

I have been looking for quite some time now, but I find myself still unable to understand how I would take the idea and apply it to an image made up of a set of points like the one above. From the wikipedia article I have the function:

$G(X) = \frac{1}{\sqrt{2\pi\sigma^2}}e^{-\frac{x^2}{2\sigma^2}}$

However, I have no idea how I actually apply that to my list of points to get a smoothed image. All of the examples online are both incredibly complicated and also for pixel-images, where every pixel in your image matters. Here, I only actually have the 20 or so points. So, what I am looking for is some explanation and advice regarding how I would apply a Gaussian blur in my way of representing the image – what do I apply $G(X)$ to (each co-ordinate?), how I calculate $\sigma^2$, etc.

The disclaimer: As stated, this is part of an assignment. However, this is not breaking any rules or 'cheating' in any form. The assignment is to investigate many features of online character recognition, not to magically know how to do one of the possible techniques for pre-processing the characters. Should I gain any knowledge of how to do the smoothing from this site, the site (and the individual, should they wish) will of course be credited in full.

I thank you for any help. I hope this question is placed correctly (I felt it was more mathematical than program-based, since it's more about the concept of Gaussian blurs rather than the implementation – I'm fairly sure I'll be able to handle that part) and that it is clear. If it is not, please just ask and I will clarify any points I can.

(I also apologise for the tag. I'm fairly sure it's inaccurate. But there's no 'Gaussian' tag. Tis odd.)

Best Answer

The industry standard way of doing this is is to calculate a "mask" of sorts, and apply it to each one.

By "mask", I mean, say, a function for the current point based on the points before and after. For example:

$f(x) = \frac{1}{9}[x-2] + \frac{2}{9}[x-1] + \frac{3}{9}[x] + \frac{2}{9}[x+1] + \frac{1}{9}[x+2] $

where $[p]$ is the value of the pixel at $p$.

So to find the new pixel value at, say, pixel $4$, you'd use $ \frac{1}{9}[2] + \frac{2}{9}[3] + \frac{3}{9}[4] + \frac{2}{9}[5] + \frac{1}{9}[6] $ (remembering that, say, $[3]$ is the value of pixel 3)

All that's left to do is then apply your mask to every pixel. (What should you use for pixels that are close to the edge? That's up to you.)

Note that to be a true blurring mask, your coefficients must add up to 1.

A "Gaussian Blur" is just applying a special mask based off of the Gaussian Curve to your pixels.

That is, you make the "coefficient" of each term a number based off of the Gaussian Curve at that point.

For example, wikipedia lists:

$f(x) = 0.00038771[x-3] + 0.01330373[x-2] + 0.11098164[x-1] + 0.22508352[x] + 0.11098164[x+1] + 0.01330373[x+2] + 0.00038771[x+2]$

as a mask with σ = 0.84089642 and a "cut-off" radius of 3, although you can pick your own standard deviation and cut-off radius to your liking.

Related Question