回答編集履歴
1
ソース修正
answer
CHANGED
@@ -22,4 +22,22 @@
|
|
22
22
|
fnm = re.search(r'[^/\.]+(?=.jpg)', f).group(0)
|
23
23
|
plt.savefig(f'output/{fnm}.png')
|
24
24
|
np.savetxt(f"output/{fnm}.csv",hists,delimiter=",")
|
25
|
-
```
|
25
|
+
```
|
26
|
+
**追記**
|
27
|
+
pltに対して追記されてるようですね。
|
28
|
+
```python
|
29
|
+
for f in files:
|
30
|
+
img = cv2.imread(f)
|
31
|
+
color = ('b','g','r')
|
32
|
+
hists = []
|
33
|
+
fig = plt.figure()
|
34
|
+
for i, col in enumerate(color):
|
35
|
+
hist = cv2.calcHist([img], [i], None, [256], [0, 256])
|
36
|
+
hists.append(hist.squeeze(axis=-1))
|
37
|
+
plt.plot(hist, color=col)
|
38
|
+
plt.xlim([0, 256])
|
39
|
+
fnm = re.search(r'[^/\.]+(?=.jpg)', f).group(0)
|
40
|
+
plt.savefig(f'output/{fnm}.png')
|
41
|
+
np.savetxt(f"output/{fnm}.csv",hists,delimiter=",")
|
42
|
+
```
|
43
|
+
これでどうでしょうか。
|