Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if let croppedImage = self.cropImage2(image: UIImage(ciImage: image), rect: rect)?.cgImage {
- let commandBuffer = self.commandQueue.makeCommandBuffer()!
- let laplacian = MPSImageLaplacian(device: self.device)
- let textureLoader = MTKTextureLoader(device: self.device)
- let options: [MTKTextureLoader.Option : Any]? = nil
- let srcTex = try! textureLoader.newTexture(cgImage: croppedImage, options: options)
- let desc = MTLTextureDescriptor.texture2DDescriptor(pixelFormat: srcTex.pixelFormat, width: srcTex.width, height: srcTex.height, mipmapped: false)
- let lapTex = self.device.makeTexture(descriptor: desc)
- laplacian.encode(commandBuffer: commandBuffer, sourceTexture: srcTex, destinationTexture: lapTex!)
- let output = CIImage(mtlTexture: lapTex!, options: [:])?.cgImage
- print("output: (output?.width)")
- print("")
- }
- let lapTex = self.device.makeTexture(descriptor: desc)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement