2
votes

I have some data set where each object has a Value and Price. I want to apply Gaussian Blur to their Price using their Value. Since my data has only 1 component to use in blurring, I am trying to apply 1D Gaussian blur.

My code does this:

totalPrice = 0;
totalValue = 0;
for each object.OtherObjectsWithinPriceRange()
    totalPrice += price;
    totalValue += Math.Exp(-value*value);

price = totalPrice/totalValue;

I see good results, but the 1D Gaussian blur algorithms I see online seems to use deviations, sigma, PI, etc. Do I need them, or are they strictly for 2D Gaussian blurs? They combine these 1D blur passes as vertical and horizontal so they are still accounting for 2D.

Also I display the results as colors but the white areas are a little over 1 (white). How can I normalize this? Should I just clamp the values to 1? That's why I am wondering if I am using the correct formula.

1
what are you doing? what language are you using? are you trying to display something? what, exactly, are you displaying? what are the "good results" that you are seeing? what is exp(-value,value) supposed to mean? i could probably help you but i cannot work out what on earth you are actually trying to do. please be much more explicit. - andrew cooke
Just an experiment. Imagine the objects as "goods" and I am trying to blur their "Price" values just like RGB values of an image, except this is a float. Language is C#, but any language is fine. - Joan Venge
What is exp(-value,value)? Isn't exp supposed to take one arg only? I fail to see blurring in your example. Blurring is convolution, every output pixel is supposed to be some combination of the surrounding pixels. - Arik G
Sorry fixed it now. THe loop basically loops for objects within a price range. So if the price range is 100, then for every object, it will loop through all other objects that have the same price range -/+100. - Joan Venge

1 Answers

1
votes

Your code applies some sort of a blur, though definitely not Gaussian. The Gaussian blur would look something like

kindaSigma = 1;
priceBlurred = object.price;
for each object.OtherObjectsWithinPriceRange()
   priceBlurred += price*Math.Exp(-value*value/kindaSigma/kindaSigma);

and that only assuming that value is proportional to a "distance" between the object and other objects within price range, whatever this "distance" in your application means.

To your questions.

  1. 2D Gaussian blur is completely equivalent to a combination of vertical and horizontal 1D Gaussian blurs done one ofter another. That's how thee 2D Gaussian blur is usually implemented in practice.

  2. You don't need any PI or sigmas as a multiplicative factor for the Gaussian - those have an effect of merely scaling an image and can be safely ignored.

  3. The sigma (standard deviation) under the exponent has a major impact on the result, but it is not possible for me to tell you if you need it or not. It depends on your application. Want more blur: use larger kindaSigma in the snippet above. Want less blur: use smaller kindaSigma. When kindaSigma is too small, you won't notice any blur at all. When kindaSigma is too large, the Gaussian blur effectively transforms itself into a moving average filter. Play with it and choose what you need.

  4. I am not sure I understand your normalization question. In image processing it is common to store each color component (R,G,B) as unsigned char. So black color is represented by (0,0,0) and white color by (255,255,255). Of course, you are free to decided to choose a different presentation form and take white color as 1. But keep in mind that for the visualization packages that are using standard 8-bit presentation, the value of 1 means almost black color. So you will likely need to manipulate and renormalize your image before display.