简体   繁体   中英

CIFilter applying to selected area using swift - ROI

I am using CIFilter for editing video and images with Swift 3.0.

Its working fine, for whole image or video.But I want to apply filter to only selected area. I found, It can be done through ROI But, all the documentation i found, is related to custom filters only.

Is there any way to use existing CIFIlters with ROI function? ie applying filter on selected area only?

You could;

  1. Convert your UIImage into CIImage.
  2. Then you would be able to extract the region you want your filter to be applied, after applying the filter you will have the CIImage as output.
  3. Merge your source CIImage and the filter-applied-CIImage from step 2.
  4. Finally convert your CIImage from step 3 to a UIImage.

If done properly all this can be nicely abstracted inside a function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM