Wenbo
Wenbo

Reputation: 1082

Partially blurring UIImage in objective C

I know how to blur a whole image, but I just want to blur a part of the image like the face. Answers are appreciated. Thanks!

Upvotes: 2

Views: 1852

Answers (2)

Wenbo
Wenbo

Reputation: 1082

Just to close this thread, I used both @Anshu's and @Michael's suggestions. Here are my steps:

  1. Crop the part the image that needs blurred.
  2. Use UIImage+Stack to blur the cropped image.
  3. Place the blurred image on top of the original image.
  4. Combine the two images together to one new image.

Upvotes: 4

Michael Robinson
Michael Robinson

Reputation: 29508

This should get you started: https://github.com/tomsoft1/StackBluriOS ?

You could look inside the UIImage+Stack implementation and use what you find there to make a version of this method that blurs a specific section of your image.

Something like:

- (UIImage*) stackBlur:(NSUInteger)inradius insideRect:(NSRect)rect;

Hint: the code from line #166 is where the blur class starts looping over the image pixels and blurring them.

Upvotes: 3

Related Questions