nail.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:Virtual-Makeup 作者: badarsh2 项目源码 文件源码
def applyTexture(x, y, texture = texture_input):
    text = imread(texture_input)
    height,width = text.shape[:2]
    xmin, ymin = amin(x),amin(y)
    xmax, ymax = amax(x),amax(y)
    scale = max(((xmax - xmin + 2)/height),((ymax - ymin + 2)/width))
    text = imresize(text, scale)
    # print text.shape[:2]
    # print xmax - xmin +2, ymax - ymin+2
    X = (x-xmin).astype(int)
    Y = (y-ymin).astype(int)
    val1 = color.rgb2lab((text[X, Y]/255.).reshape(len(X), 1, 3)).reshape(len(X), 3)
    val2 = color.rgb2lab((im[x, y]/255.).reshape(len(x), 1, 3)).reshape(len(x), 3)
    L, A, B = mean(val2[:,0]), mean(val2[:,1]), mean(val2[:,2])
    val2[:, 0] = np.clip(val2[:, 0] - L + val1[:,0], 0, 100)
    val2[:, 1] = np.clip(val2[:, 1] - A + val1[:,1], -127, 128)
    val2[:, 2] = np.clip(val2[:, 2] - B + val1[:,2], -127, 128)
    im[x,y] = color.lab2rgb(val2.reshape(len(x), 1, 3)).reshape(len(x), 3)*255

# points = np.loadtxt('nailpoint_5')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号