回答編集履歴
1
ソース修正
test
CHANGED
@@ -47,3 +47,39 @@
|
|
47
47
|
np.savetxt(f"output/{fnm}.csv",hists,delimiter=",")
|
48
48
|
|
49
49
|
```
|
50
|
+
|
51
|
+
**追記**
|
52
|
+
|
53
|
+
pltに対して追記されてるようですね。
|
54
|
+
|
55
|
+
```python
|
56
|
+
|
57
|
+
for f in files:
|
58
|
+
|
59
|
+
img = cv2.imread(f)
|
60
|
+
|
61
|
+
color = ('b','g','r')
|
62
|
+
|
63
|
+
hists = []
|
64
|
+
|
65
|
+
fig = plt.figure()
|
66
|
+
|
67
|
+
for i, col in enumerate(color):
|
68
|
+
|
69
|
+
hist = cv2.calcHist([img], [i], None, [256], [0, 256])
|
70
|
+
|
71
|
+
hists.append(hist.squeeze(axis=-1))
|
72
|
+
|
73
|
+
plt.plot(hist, color=col)
|
74
|
+
|
75
|
+
plt.xlim([0, 256])
|
76
|
+
|
77
|
+
fnm = re.search(r'[^/\.]+(?=.jpg)', f).group(0)
|
78
|
+
|
79
|
+
plt.savefig(f'output/{fnm}.png')
|
80
|
+
|
81
|
+
np.savetxt(f"output/{fnm}.csv",hists,delimiter=",")
|
82
|
+
|
83
|
+
```
|
84
|
+
|
85
|
+
これでどうでしょうか。
|