使用該dlib庫,我能夠從一張影像(蒙版)中屏蔽嘴巴特征。
蒙面

同樣,我還有另一個沒有面具(colorlip)的嘴巴裁剪影像。
彩唇

我已經縮放并替換了影像(已替換)并使用np.where,如下面的代碼所示。
取代

#Get the values of the lip and the target mask
lip = pred_toblackscreen[bbox_lip[0]:bbox_lip[1], bbox_lip[2]:bbox_lip[3],:]
target = roi[bbox_mask[0]:bbox_mask[1], bbox_mask[2]:bbox_mask[3],:]
cv2.namedWindow('masked', cv2.WINDOW_NORMAL)
cv2.imshow('masked', target)
#Resize the lip to be the same scale/shape as the mask
lip_h, lip_w, _ = lip.shape
target_h, target_w, _ = target.shape
fy = target_h / lip_h
fx = target_w / lip_w
scaled_lip = cv2.resize(lip,(0,0),fx=fx,fy=fy)
cv2.namedWindow('colorlip', cv2.WINDOW_NORMAL)
cv2.imshow('colorlip', scaled_lip)
update = np.where(target==[0,0,0],scaled_lip,target)
cv2.namedWindow('replaced', cv2.WINDOW_NORMAL)
cv2.imshow('replaced', update)
但是 'colorlip' 中的特征形狀(嘴唇)與 'masked' 影像不匹配。因此,存在未對齊的情況,并且蒙版的邊緣看起來很清晰,就好像影像已被覆寫一樣。如何解決這個問題呢?以及如何使最終替換的影像看起來更加微妙和正常?
uj5u.com熱心網友回復:
**更新 #2:OpenCV 影像修復以平滑鋸齒狀邊框。

輸出影像




**更新 #1:添加了基于深度影像協調的混合方法。
嘗試使用
Rough Mask Image

Destination Image

Final Image

Reference
- https://docs.opencv.org/4.5.4/df/da0/group__photo__clone.html
- https://learnopencv.com/seamless-cloning-using-opencv-python-cpp/
- https://learnopencv.com/face-swap-using-opencv-c-python/
- https://github.com/JiahuiYu/generative_inpainting
- https://docs.opencv.org/4.x/df/d3d/tutorial_py_inpainting.html
Deep Image Harmonization
- https://github.com/bcmi/Image-Harmonization-Dataset-iHarmony4
- https://github.com/wasidennis/DeepHarmonization
- https://github.com/saic-vul/image_harmonization
- https://github.com/wuhuikai/GP-GAN
- https://github.com/junleen/RainNet
- https://github.com/bcmi/BargainNet-Image-Harmonization
- https://github.com/vinthony/s2am
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/352470.html
上一篇:如何使用GIMP防止色帶?
