Are the GPUImageBilateralFilter parameters of the GPUImage iOS Library the equivilent of Photoshop Surface Blur parameters?

StackOverflow https://stackoverflow.com/questions/20817630

  •  22-09-2022
  •  | 
  •  

Question

I understand that a Surface Blur in Photoshop is a bilateral filter.

In the iOS Library GPUImage there is a filter GPUImageBilateralFilter with parameters of texelSpacingMultiplier and distanceNormalizationFactor.

Would these match up directly to the Photoshop Surface Blur options of radius and threshold (respectively)? And would the values to these parameters be the same?

Thanks!

Was it helpful?

Solution

Not exactly.

With your standard Gaussian blurs, you typically specify a pixel radius (or sigma value in pixels) to define the blur strength. Before the recent overhaul of the blurs, you couldn't specify something like this in GPUImage. The blurs instead used a fixed number of samples, with a fixed value of sigma. You could expand them slightly by adjusting the pixel spacing between samples (the texelSpacingMultiplier, which is 1.0 by default).

With my recent revamp of the blurs, you now can specify a true pixel radius for the blur, which in the case of a Gaussian blur sets the size of sigma. When you do this, it generates a shader on the fly that works over the appropriate number of pixels to yield a blur of that strength. The use of sigma here matches Core Image's behavior exactly, although I haven't tested it against Photoshop.

However, the bilateral blur is the last of the blurs that I've needed to update to bring it inline with the others. I haven't yet, so you don't have a great way to bring it in line with Photoshop's behavior yet. This is on my to-do list, but that's fairly lengthy at this point. You're welcome to take a look at how I converted over something like the box blur and to try to adapt the bilateral blur math to enable this for that filter.

The distanceNormalizationFactor isn't related to the blur size, but it works to weight the way that pixel colors are processed from the sampled pixels around the central one. A bilateral blur works by blurring the central color only with surrounding colors that are close enough to the central one (thus preserving edges). This weighting value controls how close a color needs to be to the central pixel's color in order for the center pixel to be blended with it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top