Comment detail
モノクロ画像の類似検索 (Nested Flatten)
Squeak Smalltalk のいったん読み込んでから一気に比較する版。選定にかかった時間(最後の式の処理時間)は 1 GHz PowerPC (Mac OS X) で 1 秒ほどでした。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | | indexOfRef refImage numOfImgs images |
indexOfRef := 1.
numOfImgs := 100.
images := (1 to: numOfImgs) collect: [:idx |
| name file |
name := (idx printPaddedWith: $0 to: 3), '.png'.
file := FileStream fileNamed: name.
file binary.
(PNGReadWriter createAFormFrom: file contentsOfEntireFile) first].
refImage := images at: indexOfRef.
((1 to: numOfImgs) copyWithout: indexOfRef) detectMin: [:idx |
(refImage deltaFrom: (images at: idx)) primCountBits]
|
参考まで、#deltaForm: の中身はビット列の XOR で、#primCountBits の中身は popCount です。いずれも、Smalltalk システム(暫定ダイナブック環境、あるいは ALTO コンピュータ)発祥ということでよく知られている BitBlt という機構が下請けています。http://ja.wikipedia.org/wiki/Bitblt





sumim
#1763()
[
Smalltalk
]
Rating0/0=0.00
| indexOfRef getImage refImage numOfImgs | indexOfRef := 1. numOfImgs := 100. getImage := [:index | | name file | name := (index printPaddedWith: $0 to: 3), '.png'. file := FileStream fileNamed: name. file binary. (PNGReadWriter createAFormFrom: file contentsOfEntireFile) first]. refImage := getImage value: indexOfRef. ((1 to: numOfImgs) copyWithout: indexOfRef) detectMin: [:idx | (refImage deltaFrom: (getImage value: idx)) primCountBits]Rating0/0=0.00-0+
1 reply [ reply ]