3DMP

선형적 샘플링으로 효율적인 가우시안 블러

알고리즘 & 자료구조/3D알고리즘&자료구조

선형적 샘플링으로 효율적인 가우시안 블러

3DMP 2012. 10. 27. 14:10

  • #1 written by djmj
    about 7 months ago

    You are looking up 10 and not 9 pixels! Coordinate 0.0 intersects two pixels and so you take full advantage of linear interpolation! Else you need to offset by half a pixel!

    Where is the benefit of the usual easier way? Lookup at coordinates [-4, -2, 0, 2, 4] to get 10 pixel range and then apply the weighting of each two texels and calculate final value?

  • #2 written by Andrew Moffat
    about 6 months ago

    Hi Daniel,

    This article was incredibly clear and informative. Thank you for taking the time to put it together. I’m still learning this stuff, so this was very helpful.

    I wrote up a small Python script based on this post to generate the gaussian texture lookups, optimized for linear sampling. Maybe it can be useful to someone else too:

    https://gist.github.com/2332010

    Thanks again

  • #3 written by Oskar Elek
    about 1 month ago

    Hey Daniel,

    nice article, the connection with Pascal’s triangle is indeed very interesting.

    I would like to add two things. First, maybe it would be good to add that Gaussian has a unit integral, since it’s probably one of the reasons the filtering works (in the continuous case at least). The 3D plot should also reflect this (meaning that such a wide Gaussian certainly wouldn’t reach a value of 1.6). This is of course just minor.

    The second thing that struck me was:
    “A Gaussian function with a distribution of 2σ is equivalent with the product of two Gaussian functions with a distribution of σ.”
    This is just my opinion, but I think this doesn’t hold. First, I think such product won’t be a 2σ-Gaussian (properly normalized and all). Second, a repeated application of any filter corresponds to applying their *convolution*, which differs from product. And, convolution of two Gaussians with StD=σ produces a Gaussian with StD=Sqrt(2*σ^2)=σ*Sqrt(2).

    I think what you meant was that product of 2 polynoms with order n (n-th row of Pascal triangle) gives you a polynom of order 2n? That should be true.

    What do you think?
    Oskar

  • #4 written by Christian Cann Schuldt Jensen
    about 1 month ago

    You can do a 9-tap gaussian using only 2 texture fetches by sampling at one of corner of the center pixel in the first pass (f.x with an xy-offset of -0.5,0.5 ) and then sample the opposite corner in the next pass ( xy-offset of 0.5,-0.5 )

    This results in the standard
    121
    242
    121
    9-tap gaussian.

    You can do the same gaussian in a single pass if you sample at all 4 corners (4 texture fetches)

    You can do a nice and very fast 7-tap blur in a single pass if you sample two opposite corners with an offset of 1/3 away from the center.

    This results in a
    121
    282
    121
    convolution kernel.
    If you calculate the strength of the blur by subtracting from the center pixel you can then scale the result so that it closely matches the regular 9-tap gaussian.

    I also do a 17-tap blur using only 5 fetches in a single pass by sampling the center pixel and then offsets (0.4,-1.2) , (-1.2,-0.4) , (1.2,0.4) and (-0.4,1.2).
    I then adjust the strength of it to more closely match the 9-tap gaussian.

반응형