Skip to content
try! Swift 2019 demo app that converts Depth-less 2D images into Portrait mode.
Branch: master
Clone or download
Latest commit ebe3703 Mar 26, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Pods $ pod install Mar 17, 2019
Portrait.xcodeproj
Portrait.xcworkspace
Portrait
.gitignore
LICENSE Initial commit Mar 17, 2019
Podfile
Podfile.lock first commit Mar 17, 2019
README.md

README.md

Portrait-without-Depth-ios

MIT License Twitter

try! Swift 2019 demo app that converts Depth-less 2D images into Portrait mode.

How to build

  1. Download opencv2.framework from here v3.4.5 iOS pack, then put it into this folder.
  2. Open Portrait.xcworkspace with Xcode 10.x and build it

About this app

In iOS’s Portrait mode, you can take beautiful photos that keep your subject sharp while blurring the background.
This so-called bokeh effect can be done by using Depth.
In contrast, this app attempts to make Depth-less 2D images into Portrait mode by following steps.

1. Segmentation ✂️

This app uses “GrabCut” to perform segmentation of the subject and the background.

GrabCut with Rect

grabcut-with-rect

GrabCut with Mask

grabcut-with-mask

2. Color leak prevention 🎨

As it’s not beautiful if the subject color leaks into the background, this app tries to delete the subject from the background by using “Inpainting”.

Blur & Inpainting

blur-and-inpainting

3. Depth-of-Field 📷

“Depth-of-Field” is the range where the photo is in focus.
I implemented an adjusting function to blur an area.

Adjust

adjust-depth-of-field

Result
before ← → after

Please give it a try !

Requirement

Xcode 10.x
iOS 12.0+

Author

Rina Kotake

Licenses

Special Thanks

You can’t perform that action at this time.