views:

38

answers:

1

When applying a Gaussian blur to an image, typically the sigma is a parameter (examples include Matlab and ImageJ).

How does one know what sigma should be? Is there a mathematical way to figure out an optimal sigma? In my case, i have some objects in images that are bright compared to the background, and I need to find them computationally. I am going to apply a Gaussian filter to make the center of these objects even brighter, which hopefully facilitates finding them. How can I determine the optimal sigma for this?

+3  A: 

There's no formula to determine it for you; the optimal sigma will depend on image factors - primarily the resolution of the image and the size of your objects in it (in pixels).

Also, note that Gaussian filters aren't actually meant to brighten anything; you might want to look into contrast maximization techniques - sounds like something as simple as histogram stretching could work well for you.

edit: More explanation - sigma basically controls how "fat" your kernel function is going to be; higher sigma values blur over a wider radius. Since you're working with images, bigger sigma also forces you to use a larger kernel matrix to capture enough of the function's energy. For your specific case, you want your kernel to be big enough to cover most of the object (so that it's blurred enough), but not so large that it starts overlapping multiple neighboring objects at a time - so actually, object separation is also a factor along with size.

Since you mentioned MATLAB - you can take a look at various gaussian kernels with different parameters using the fspecial('gaussian', hsize, sigma) function, where hsize is the size of the kernel and sigma is, well, sigma. Try varying the parameters to see how it changes.

tzaman
@tzaman: can you expand on how the optimal sigma depends on the resolution of the image and the size of my objects in pixels? or point me in the direction of readings if you can. that's exactly what i'm looking for. also, i misspoke about brightening; i meant to say i want the center of my objects to be relatively bright to everything else.
hatorade
@hatorade: I've expanded my answer; hope it clarifies things.
tzaman
@tzaman: on a website (http://imaging.mrc-cbu.cam.ac.uk/imaging/PrinciplesSmoothing) I read that the Full Width at Half Maximum (FWHM) measure has an equation. Does this concept hold for the kernel? As in, in ImageJ or Matlab, does the "FWHM" of the kernel relate to sigma in the same way? The reason I ask is because usually the parameters are the kernel dimensions, and sigma, but i keep reading that sigma effects the kernel size...
hatorade
@hatorade: Yes - essentially, FWHM is one way to measure the "spread" of the function itself; so it'll be larger for higher sigma. You could, for example, use it to help determine how big the matrix size for a given kernel _should_ be. While in some sense you can pick dimension and sigma separately, in reality the dimension has to be tied to the sigma for it to be meaningful - it needs to be big enough to preserve the shape of the curve; if you truncate it too much, it stops being a Gaussian blur and more or less turns into a simple average-filter.
tzaman
@tzaman: right. do you know if there is an equation for the width of the base of the normal curve, and not at half max? essentially, i know how big i want the kernel to be, but I don't know how to calculate sigma from that (so going from kernel size -> sigma instead of sigma -> kernel size)
hatorade
@hatorade: Gaussians are essentially infinite, although they drop down to negligible values as you go further out, so there's no "limit" on the width of the base. Twice the FWHM or something like that sounds reasonable. Also, even at a particular kernel size, you can vary the sigma meaningfully (there's no "one best sigma" for any given kernel) - think of it as multiplying your Gaussian filter with a box filter of those dimensions.
tzaman