Click here to Skip to main content
15,748,330 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
please help me.

thanks in advance.
Updated 26-Nov-11 21:30pm
Sergey Alexandrovich Kryukov 27-Nov-11 1:44am    
And what kind of comparison is required? And why? Definition, please... :-)
chieto 30-Dec-11 5:08am    
2 images. . compared any idea?

Share this answer
Strictly speaking, the question as it is formulated does not make sense. A comparison is a category which needs definitions for every class of objects. It is defined for numbers, strings, but not for images. The only apparent natural part of definition is equivalence, but comparison also implies <=, >=…

In practice, equivalence of images pixel-to-pixel is rarely used by applications. Extensively discussed is the idea of recognition of "similar" images, which is extremely difficult even to formulate in a practically sensible way.

Share this answer
Try this one :
Private Sub btnCheck_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles btnGo.Click
    Me.Cursor = Cursors.WaitCursor
    ' Get the threshold.
    Dim threshold As Integer = _
    ' Load the images.
    Dim bmp1 As Bitmap = Image.FromFile(txtFile1.Text)
    Dim bmp2 As Bitmap = Image.FromFile(txtFile2.Text)
    ' Make a difference image.
    Dim wid As Integer = Math.Min(bmp1.Width, bmp2.Width)
    Dim hgt As Integer = Math.Min(bmp1.Height, bmp2.Height)
    Dim bmp3 As New Bitmap(wid, hgt)
    ' Create the difference image.
    Dim are_identical As Boolean = True
    Dim r1, g1, b1, r2, g2, b2, r3, g3, b3 As Integer
    Dim color1, color2 As Color
    Dim eq_color As Color = Color.White
    Dim ne_color As Color = Color.Red
    Dim dr, dg, db, diff As Integer
    For x As Integer = 0 To wid - 1
        For y As Integer = 0 To hgt - 1
            color1 = bmp1.GetPixel(x, y)
            color2 = bmp2.GetPixel(x, y)
            dr = CInt(color1.R) - color2.R
            dg = CInt(color1.G) - color2.G
            db = CInt(color1.B) - color2.B
            diff = dr * dr + dg * dg + db * db
            If diff <= threshold Then
                bmp3.SetPixel(x, y, eq_color)
                bmp3.SetPixel(x, y, ne_color)
                are_identical = False
            End If
        Next y
    Next x
    ' Display the result.
    picResult.Image = bmp3
    Me.Cursor = Cursors.Default
    If (bmp1.Width <> bmp2.Width) OrElse (bmp1.Height <> _
        bmp2.Height) Then are_identical = False
    If are_identical Then
        MessageBox.Show("The images are identical")
        MessageBox.Show("The images are different")
    End If
End Sub
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900