Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
efficient way to compare 2 images?
#15
squish the two images down to a really small image. If they don't match when they are 2 by 2 pixels they sure aren't going to match when they are say 200 by 200 pixels. 
if it matches keep comparing pixels by pixel in slightly larger scaled image until back up to original size.


crude example:
Code: (Select All)
Screen _NewImage(800, 500, 32)
i1& = _NewImage(200, 200, 32)
i2& = _NewImage(200, 200, 32)
Dim p1 As _Unsigned Long
Dim p2 As _Unsigned Long
Randomize Timer
_Dest i1&
'x1 = Int(Rnd * _Width / 2): x2 = Int(Rnd * _Width / 2 + x1)
'y1 = Int(Rnd * _Height / 2): y2 = Int(Rnd * _Height / 2 + y1)
'Line (x1, y1)-(x2, y2), _RGB32(100, 100, Int(Rnd * 8) + 100), BF
Line (0, 0)-(10, 10), _RGB32(100, 100, 100), BF
_Dest i2&
'x1 = Int(Rnd * _Width / 2): x2 = Int(Rnd * _Width / 2 + x1)
'y1 = Int(Rnd * _Height / 2): y2 = Int(Rnd * _Height / 2 + y1)
'Line (x1, y1)-(x2, y2), _RGB32(100, 100, Int(Rnd * 8) + 100), BF
Line (0, 0)-(10, 11), _RGB32(100, 100, 100), BF
_Dest 0
_PutImage (0, 201), i1&
_PutImage (201, 201), i2&

flagcount = 0
threshold = 2
pass = 0
For xmax = 2 To _Width(i1&) Step 10
    pass = pass + 1
    Locate 1, 1: Print pass 'this really just gives you something to look at
    For ymax = 2 To _Height(i1&) Step 10
        _Limit 100
        a& = _NewImage(xmax, ymax)
        b& = _NewImage(xmax, ymax)
        _PutImage (0, 0)-(xmax, ymax), i1&, a&, (0, 0)-(_Width(i1&), _Height(i1&))
        _PutImage (0, 0)-(xmax, ymax), i2&, b&, (0, 0)-(_Width(i2&), _Height(i2&))
        For py = 1 To ymax
            For px = 1 To xmax
                _Source a&
                p1 = Point(px, py)
                _Source b&
                p2 = Point(px, py)
                If p1 <> p2 Then flagcount = flagcount + 1
                If flagcount >= threshold Then GoTo notthesame
            Next
        Next

    Next
Next
Locate 2, 2
Print "IMAGES are IDENTICAL"
End
notthesame:
Locate 2, 2
Print "IMAGES ARE NOT IDENTICAL"
Reply


Messages In This Thread
efficient way to compare 2 images? - by madscijr - 11-18-2022, 07:51 PM
RE: efficient way to compare 2 images? - by bplus - 11-18-2022, 08:10 PM
RE: efficient way to compare 2 images? - by Pete - 11-18-2022, 08:26 PM
RE: efficient way to compare 2 images? - by Pete - 11-18-2022, 08:55 PM
RE: efficient way to compare 2 images? - by James D Jarvis - 11-18-2022, 09:21 PM
RE: efficient way to compare 2 images? - by Pete - 11-18-2022, 09:30 PM
RE: efficient way to compare 2 images? - by Pete - 11-18-2022, 09:52 PM
RE: efficient way to compare 2 images? - by Pete - 11-18-2022, 11:08 PM
RE: efficient way to compare 2 images? - by bplus - 11-18-2022, 11:40 PM
RE: efficient way to compare 2 images? - by bplus - 11-19-2022, 12:22 AM
RE: efficient way to compare 2 images? - by bplus - 11-19-2022, 01:22 AM
RE: efficient way to compare 2 images? - by bplus - 11-19-2022, 05:39 PM
RE: efficient way to compare 2 images? - by bplus - 11-19-2022, 06:28 PM
RE: efficient way to compare 2 images? - by bplus - 11-19-2022, 10:54 PM
RE: efficient way to compare 2 images? - by bplus - 11-19-2022, 11:54 PM
RE: efficient way to compare 2 images? - by bplus - 11-19-2022, 11:57 PM
RE: efficient way to compare 2 images? - by bplus - 11-20-2022, 12:02 AM
RE: efficient way to compare 2 images? - by bplus - 11-20-2022, 12:14 AM
RE: efficient way to compare 2 images? - by bplus - 11-20-2022, 12:36 AM
RE: efficient way to compare 2 images? - by bplus - 11-20-2022, 02:37 AM



Users browsing this thread: 24 Guest(s)