Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 298
  • Last Modified:

compare two images pixel by pixel

how is it possible to compare two images and tell in what areas they're different..?
0
davidlars99
Asked:
davidlars99
  • 4
  • 2
1 Solution
 
S-TwilleyCommented:
Sorry about the delay in helping with this...

Just wanted to check really... you want to check every single pixel... or possibly a set area?

Also, is this like a one off comparison of two images... or will it be continuous checking of a new Image... and the last image... like if you were captuing a webcam image, and wanted to monitor for a change (especially in this case, you may want to limit the number of pixels)
0
 
davidlars99Author Commented:
thanks Steve, you can give me all you can and I'll start researching by myself then, just put me into right direction...  :)
0
 
S-TwilleyCommented:
Well this is the less efficient way (I've since seen a better way but have not implemented it).

' BitmapA and BitmapB are bitmap objects...

                Dim different As Boolean = False
                If BitmapA.Size.Equals(BitmapB.Size) Then
                    Dim xcoord, ycoord As Single
                    Dim pixelA, pixelB As Color

                    For xcoord = 0 To BitmapA.Width - 1
                        For ycoord = 0 To BitmapA.Height - 1
                            pixelA = BitmapA.GetPixel(xcoord, ycoord)
                            pixelB = BitmapB.GetPixel(xcoord, ycoord)

                            If Not pixelA.Equals(pixelB) Then
                                different = True
                                Exit For
                            End If
                        Next
                        If different Then Exit For
                    Next
                Else
                    different = True
                    'Different sizes
                End If

                If different Then
                    MsgBox("The bitmaps are different")
                Else
                    MsgBox("The bitmaps are the same")
                End If

==================

I'll try and work on the better version that doesn't use GetPixel now... but there's something for you to work with
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
S-TwilleyCommented:
just a note:   this is assuming that you're not using a fixed pallete on the bitmaps, you should probably test for differing pallettes as well... but i was assuming that they're in true color
0
 
S-TwilleyCommented:
well   using LockBits is supposed  to be better than using GetPixel

http://www.bobpowell.net/lockingbits.htm

but I'm not sure about the Marshal.WriteByte part...   it's meant to be more efficient, but if you limit the number of comparisons, GetPixel shouldn't be too much of a resource hog
0
 
davidlars99Author Commented:
thanks Steve, I liked it
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now