We depends heavily on Images these days, and sometimes developers need to make processing on these files and one of these things that give us headache is backgorund removal, I really hate that there are so few open source background removal models and libraries so I decided to make this library open source so people can use it, If this suits your need, give it a try
Background removal can give you two different outouts
- Mask Image: The mask for your input image (black & white) so you can do any processing that you needs
- Output image: ( default case) your output image without its background
And, it has zero dependencies
To start the background removal on your image you just need to pass a
UIImage component to the library and get your output image, only that
let image = UIImage(named: "child") outputImage.image = BackgroundRemoval.init().removeBackground(image: image!)
The output will always be a
UIImage in all cases.
In case you wanted only The mask for your input image (black & white), then you case pass
maskOnly arg to the library
let image = UIImage(named: "child") segmentedImage.image = BackgroundRemoval.init().removeBackground(image: image!, maskOnly: true)
you may see some shadows on the edges after you remove the background, you can add some filters on your mask before you mask the input image to get the output result, here is an example of a good tested workaround that gave me a better resutls
let image = UIImage(named: "child") let scaledOut = BackgroundRemoval.init().removeBackground(image: image!, maskOnly: true) /// post processing to get rid of image blur let imageSource = BBMetalStaticImageSource(image: scaledOut) // Set up some filters for mask post processing let contrastFilter = BBMetalContrastFilter(contrast: 3) let sharpenFilter = BBMetalSharpenFilter(sharpeness: 1) // Set up filter chain // Make last filter run synchronously imageSource.add(consumer: contrastFilter) // .add(consumer: lookupFilter) .add(consumer: sharpenFilter) .runSynchronously = true // Start processing imageSource.transmitTexture() // Get filtered mask let filteredImage = sharpenFilter.outputTexture?.bb_image
The model supports macOS = 11, iOS = 14. however the library currently supports only iOS systems.
Mobile App Development Best Practices – 04.10
iOS New and Deprecated APIs in iOS 17 Abstract Class vs. Protocol-Oriented Approach in Swift Comparing the Performance of the...
New and Deprecated APIs in iOS 17
In this video, I would like to share with you some things that were either deprecated or added in iOS...
Promova helps people with dyslexia learn languages
The new Promova feature comes just in time for National Dyslexia Awareness Month and is available on the platform for...
Notify – A simple note application with modern MVVM, Compose and Material3
Notify is a simple note application that is built with Modern Android development tools. This project showcases the Good implementation...
Mobile App Development Best Practices – 03.10
iOS MetaCodable – Supercharge Swift’s Codable implementations with macros meta-programming How to build a Tuist plugin and publish it using...
How to make and use BOM (Bill of Materials) dependencies in Android projects
By using a BOM dependency, you can avoid specifying the versions of each individual library in your app, and let...