-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColor-3D.py
More file actions
39 lines (29 loc) · 755 Bytes
/
Color-3D.py
File metadata and controls
39 lines (29 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# -*- coding: utf-8 -*-
"""
Color-3D.py
Author: Rorical
Notator: EL_File4138
A Solution for CCBC12 Timeline F 1817.
将所读取的彩虹图投影为3D图形。
"""
from matplotlib import pyplot as plt
import cv2
img = cv2.imread("color.png")
views = [(-90, 180), (0, 0), (180, -90)]
for xrot, yrot in views:
for y in range(0, 300, 50):
X = []
Y = []
Z = []
for c in img[y]:
X.append(c[2]) #R
Y.append(c[1]) #G
Z.append(c[0]) #B
fig = plt.figure()
axis = plt.axes(projection='3d')
axis.set_xlabel('R')
axis.set_ylabel("G")
axis.set_zlabel("B")
axis.view_init(xrot, yrot)
axis.scatter3D(X, Y, Z)
plt.show()