Create a mask from an image with the background removed by rembg. Next, the original image is converted to black and white. Finally, the converted black-and-white image is masked and combined with the original background.
rembgで背景を削除した画像からマスクを作成します。次にオリジナル画像を白黒に変換します。最後に白黒画像に変換した画像をマスク処理して元の背景と合成します。
- Python 3.9.1
画像を保存するディレクトリを作成
mkdir original combine
requirements.txtからライブラリをインストール
pip install -r requirements.txt
python combine-background.py
- Create Mask from image with background removed by rembg.(rembgで背景を削除した画像からMaskを作成)
- Convert original image to grayscale.(オリジナル画像をグレースケールに変換)
- Composite the original image, B&W image, and Mask.(オリジナル画像、白黒画像、マスクを合成)
Original | rembg | Mask | Gray |
---|---|---|---|
nobnov (Nobukazu Ishii)