Skip to content

Commit b922f32

Browse files
authored
Add files via upload
1 parent 7a903a1 commit b922f32

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#coding:utf-8
2+
#By:Eastmount CSDN 2021-08-20
3+
import cv2
4+
import math
5+
import numpy as np
6+
7+
#获取滤镜颜色
8+
def getBGR(img, table, i, j):
9+
#获取图像颜色
10+
b, g, r = img[i][j]
11+
#计算标准颜色表中颜色的位置坐标
12+
x = int(g/4 + int(b/32) * 64)
13+
y = int(r/4 + int((b%32) / 4) * 64)
14+
#返回滤镜颜色表中对应的颜色
15+
return lj_map[x][y]
16+
17+
#读取原始图像
18+
img = cv2.imread('nv.png')
19+
lj_map = cv2.imread('table.png')
20+
21+
#获取图像行和列
22+
rows, cols = img.shape[:2]
23+
24+
#新建目标图像
25+
dst = np.zeros((rows, cols, 3), dtype="uint8")
26+
27+
#循环设置滤镜颜色
28+
for i in range(rows):
29+
for j in range(cols):
30+
dst[i][j] = getBGR(img, lj_map, i, j)
31+
32+
#显示图像
33+
cv2.imshow('src', img)
34+
cv2.imshow('dst', dst)
35+
36+
cv2.waitKey()
37+
cv2.destroyAllWindows()

0 commit comments

Comments
 (0)