質問編集履歴
1
自分で作成したプログラムを載せました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -56,7 +56,51 @@
|
|
56
56
|
|
57
57
|
|
58
58
|
|
59
|
+
/*****ここからは自分で作成したプログラムです。*****/
|
59
60
|
|
61
|
+
import os
|
62
|
+
|
63
|
+
import glob
|
64
|
+
|
65
|
+
from PIL import Image
|
66
|
+
|
67
|
+
import imagehash
|
68
|
+
|
69
|
+
import shutil
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
hash = imagehash.phash(Image.open(r'./testdir/bw.jpg')) #比べる元画像
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
print(hash) #確認用
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
files = glob.glob('./testdir/*') #比較したい画像が入っているフォルダ
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
for f in files:
|
86
|
+
|
87
|
+
(dirname,filename)=os.path.split(f) #ファイル名を取得
|
88
|
+
|
89
|
+
otherhash = imagehash.phash(Image.open(f)) #比較する画像
|
90
|
+
|
91
|
+
flag = hash - otherhash #ハミング距離
|
92
|
+
|
93
|
+
if flag <= 60: #ある値よりflagが小さかったらファイル名とハミング距離を表示
|
94
|
+
|
95
|
+
print(filename)
|
96
|
+
|
97
|
+
print(hash - otherhash)
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
else:
|
102
|
+
|
103
|
+
print('a') #確認用
|
60
104
|
|
61
105
|
|
62
106
|
|
@@ -82,7 +126,7 @@
|
|
82
126
|
|
83
127
|
|
84
128
|
|
85
|
-
###試したこと
|
129
|
+
###試したこと![![イメージ説明](99f148b59637f84244ceebce37b52745.jpeg)](97c1c8d6a719a05e0d1bdd450cc9a67a.jpeg)
|
86
130
|
|
87
131
|
課題に対してアプローチしたことを記載してください
|
88
132
|
|
@@ -91,3 +135,7 @@
|
|
91
135
|
###補足情報(言語/FW/ツール等のバージョンなど)
|
92
136
|
|
93
137
|
より詳細な情報
|
138
|
+
|
139
|
+
can110さんに作成していただいた確認用コードをイメージに載せた画像で動かして見ました。またその結果も載せてあります。
|
140
|
+
|
141
|
+
自分で作成したプログラムの元画像のhashは0101000001010000となりました。
|