4 ms·
Worth noting that background removal is built in to Preview on Macos.
by andrewstuart 2y ago
Worth noting that background removal is built in to Preview on Macos.
- dagmx 2y agoIt’s also built into Safari and Photos on all their platforms and available as an API that can be called by any app https://developer.apple.com/wwdc23/10176 https://developer.apple.com/wwdc23/10176
- oefrha 2y agoHuh, I've been copying background-removed subjects out of Preview and didn't realize there's a VisionKit API. Looks like it's quite easy to use too, I put together a quick and dirty script in a couple minutes and it worked wonderfully: import AppKit import VisionKit @main struct Script { static func main() async { let image = NSImage(contentsOfFile: "input.heic")! let view = ImageAnalysisOverlayView() let analyzer = ImageAnalyzer() let configuration = ImageAnalyzer.Configuration(.visualLookUp) let analysis = try! await analyzer.analyze(image, orientation: .up, configuration: configuration) view.analysis = analysis let subjects = await view.subjects for (index, subject) in subjects.enumerated() { let subjectImage = try! await subject.image let pngData = NSBitmapImageRep(data: subjectImage.tiffRepresentation!)!.representation( using: .png, properties: [:]) try! pngData?.write(to: URL(fileURLWithPath: "subject-\(index).png")) print("subject-\(index).png") } } }
- Abishek_Muthian 2y agoWas searching for an equivalent for Linux, came across rembg. https://github.com/danielgatis/rembg https://github.com/danielgatis/rembg