Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement a box or gaussian blur on iOS

I want to be able to take an image and blur it relatively quickly (say in 0.1 sec). Image size would almost never be larger than 256 x 256 px.

Do I have to loop thru every pixel and average them with neighbors or is there a higher-level way that I could do this?

PS: I am aware that multiple box blurs can approximate a gaussian blur.

like image 789
willc2 Avatar asked Jul 16 '09 20:07

willc2


People also ask

How do I add Gaussian blur?

Go to Filter > Blur > Gaussian Blur, and the Gaussian Blur window will appear. You can drag the image in the Gaussian Blur window to look for the object you are going to blur. If you find it too small, tick the Preview box, and the result of the Gaussian Filter blur will be visible in the image.

How do you put motion blur on iPhone?

You'll need blur effect apps if you want to apply motion blur effects to a current iPhone shot. They are mainly photo editing or photo blur apps. You could try the Picsart, AfterFocus, Blur Photo Editor, Snapseed, Focus In Motion, PhotoToaster, Blur Photo Background, or Blur Photo app for the motion blur effect.

What app has Gaussian blur?

CorelDRAW does more than just add gaussian blur Check out some of the other graphics design features in CorelDRAW, like font finder, clip art, page layout, vectorize, and more! Create high quality graphics in a fun and easy graphics software.


1 Answers

I found a really fast pretty crappy way for iOS3.2+ apps

  UIView *myView = [self view];
  CALayer *layer = [myView layer];
  [layer setRasterizationScale:0.25];
  [layer setShouldRasterize:YES];

This rasterizes the view down to 4x4 pixel chunks then scales it back up using bilinear filtering... it's EXTREMELY fast and looks ok if you are just wanting to blur a background view under a modal view.

To undo it, just set the rasterization scale back to 1.0 or turn off rasterization.

like image 77
Gabe Avatar answered Sep 28 '22 21:09

Gabe