// uiImage: UIImage
let ciImage = CIImage(image: uiImage)
let ciContext = CIContext(options: nil)
let cgImage = ciContext.createCGImage(ciImage, from: ciImage.extent)
// cgImage: CGImage
let ciImage = CIImage(cgImage: cgImage)
// ciImage: CIImage
let uiImage = UIImage(ciImage: ciImage)
// cgImage: CGImage
let uiImage = UIImage(cgImage: cgImage)
cf.
https://developer.apple.com/documentation/uikit/uiimage/
https://developer.apple.com/search/?q=CIImage
https://developer.apple.com/search/?q=CGImage
http://wiki.hawkguide.com/wiki/Swift:_Convert_between_CGImage,_CIImage_and_UIImage