Is this learnable? How to unwrap the skin in Python

For complex image processing such as microdermabrasion, it is obviously more complicated to use a scientific computing package such as scipy, so the artifact opencv is used.

pip install opencv-python

The essence of microdermabrasion is to blur the surface, but using blur directly will blur the edges of the contour. Therefore, it is necessary to use bilateral filtering - a filter that can play an edge-preserving role,

Since opencv comes with a window for image display, there is no need to import other drawing packages. First, open an image

import numpy as np
import cv2

img = cv2.imread("dip.jpg")
cv2.imshow("test",img)

as the picture shows

insert image description here

First, perform bilateral filtering on the image

#双边滤波,三个参数分别是
biImg = cv2.bilateralFilter(img,50,50,50)
ck = np.append(img,biIimg,axis=1)       #拼接处理前后的图像,用于对比
cv2.imshow("comparison",ck)

The comparison is as follows, it can be seen that a little effect has been produced, and the skin has obviously improved, as if the sheep placenta has been applied.

insert image description here

Among them, bilateralFilterthe bilateral filtering function in opencv, which adds edge-related weighting factors on the basis of Gauss filtering. Therefore, bilateral filtering can be understood as threshold search edge + Gauss filtering. After finding the edge, use Gauss filtering on non-edge areas, and reduce the weight of Gauss filtering for the more edge-like areas. Therefore, in addition imgto the image to be processed, the input parameters are the filter radius, the standard deviation of the Gaussian filter function, and the standard deviation of the threshold function, respectively.

Guess you like

Origin blog.csdn.net/m0_37816922/article/details/123421520