Question

How to create blur surface of photoshop in flash AS3?

I want to create surface blur effect in flash but could not find any examples of it.

Please help me! Thank you all.

Was it helpful?

Solution

From a quick look around, I wasn't able to find an example of this in Flash anywhere either, so I gave it a shot. Results were mixed... It's probably more porn blur than surface blur, but I hope it's of some use at least as a starting point.

Sample surface blur

I've put the code on wonderfl: http://wonderfl.net/c/iLgg (with another example here)

The basic idea was to apply Flash's gaussian blur filter to an image, then compare each pixel of the blurred version against the original to see how far it had deviated. The more the blur has altered a given pixel, the more it has lost important detail (and conversely, the more similar the pre- and post-blurred pixels are, the less important that smoothed out detail will likely be to appearance of the picture). The final image is then a blend of the two, with more of the source image brought back into regions with more detail.

The key parameters that affect the final appearance are:

  • blurAmount: The initial degree of gaussian blur; this has the biggest effect on the final image
  • detailProtection: Degree of detail to bring back in; higher means more detail in the final image
  • similarityThreshold: The minimum amount of discrepancy for which any original detail will be brought back in; higher means less detail

The code linked above isn't optimised, so it's not especially fast, but I hope instead it's relatively easy to see what's going on.

OTHER TIPS

I have managed to implement the Surface Blur in Javascript. It is a part of my photo editor Photopea. Try it out on this picture (choose Filter - Blur - Surface Blur).

The algorithm is called Bilateral Filtering. Put it into Google and you will find much more results, than when googling Surface Blur :) There are many scientific papers on how to do it efficiently.

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