Comment detail

モノクロ画像の類似検索 (Nested Flatten)

This comment is reply for 1763 sumim: Squeak Smalltalk で。0...(モノクロ画像の類似検索). Go to thread root.

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

Index

Feed

Other

Link

Pathtraq

loading...