Closed X901 closed 1 year ago
you can refer to this function used in the library functions to mask the image from a mask, you can use it as an extension for your input image and mask it with the output mask
`
/// mask the input image with our mask to get the final result
func maskImage(withMask maskImage: UIImage) -> UIImage {
let maskRef = maskImage.cgImage
let mask = CGImage(
maskWidth: maskRef!.width,
height: maskRef!.height,
bitsPerComponent: maskRef!.bitsPerComponent,
bitsPerPixel: maskRef!.bitsPerPixel,
bytesPerRow: maskRef!.bytesPerRow,
provider: maskRef!.dataProvider!,
decode: nil,
shouldInterpolate: false)
let masked = self.cgImage!.masking(mask!)
let maskedImage = UIImage(cgImage: masked!)
// No need to release. Core Foundation objects are automatically memory managed.
return maskedImage
}`
Hi,
I tried your example
Improve results
but the result is The mask not the image after remove background how can I get the image itself without background ?