Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - CoreImage - Add an effect to partial of image

I just have a look on CoreImage framework on iOS 5, found that it's easy to add an effect to whole image. I wonder if possible to add an effect on special part of image (a rectangle). for example add gray scale effect on partial of image/

I look forward to your help.

Thanks, Huy

like image 727
Huy Tran Avatar asked Nov 03 '22 20:11

Huy Tran


1 Answers

Watch session 510 from the WWDC 2012 videos. They present a technique how to apply a mask to a CIImage. You need to learn how to chain the filters together. In particular take a look at:

  • CICrop, CILinearGradient, CIRadialGradient (could be used to create the mask)
  • CISourceOverCompositing (put mask images together)
  • CIBlendWithMask (create final image)

Example: Pixelate faces

The filters are documented here:

https://developer.apple.com/library/archive/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html

like image 109
Felix Avatar answered Nov 15 '22 05:11

Felix