Click to See Complete Forum and Search --> : Comparing 2 images/pictures?


dev
August 20th, 2001, 02:09 AM
I have 2 images that I have loaded onto the Picture Box. I need to compare if there are any similarity in both pictures in terms of colour, or pixel values. Could you tell me how to compare the 2 images and prove the similar parts on both the pictures?
Please provide me with the functions or source code in VB. I really need help.

Thank you.
dev.

Iouri
August 20th, 2001, 07:03 AM
Open your picture as binary and compare.

'Description: Compares the content of two files

Open "file1" For Binary As #1
Open "file2" For Binary As #2
issame% = True
If LOF(1) <> LOF(2) Then
issame% = False
Else
whole& = LOF(1) \ 10000 'number of whole 10,000 byte chunks
part& = LOF(1) Mod 10000 'remaining bytes at end of file
buffer1$ = String$(10000, 0)
buffer2$ = String$(10000, 0)
start& = 1
For x& = 1 To whole& 'this for-next loop will get 10,000
Get #1, start&, buffer1$ 'byte chunks at a time.
Get #2, start&, buffer2$
If buffer1$ <> buffer2$ Then
issame% = False
Exit For
End If
start& = start& + 10000
Next
buffer1$ = String$(part&, 0)
buffer2$ = String$(part&, 0)
Get #1, start&, buffer1$ 'get the remaining bytes at the end
Get #2, start&, buffer2$ 'get the remaining bytes at the end
If buffer1$ <> buffer2$ Then issame% = False
End If
Close
If issame% Then
MsgBox "Files are identical", 64, "Info"
Else
MsgBox "Files are NOT identical", 16, "Info"
End If

Iouri Boutchkine
iouri@hotsheet.com