Results 1 to 7 of 7

Thread: Image Comparison

  1. #1

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Image Comparison

    hi buddies..
    i wanna need help about
    is there possible to compare to images in VB6.
    if yes then
    can we tell in % ...
    like
    100 % same
    75 % same ......

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

  3. #3
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Image Comparison

    If you were to compare images of the same size, you would do something like this:

    VB Code:
    1. Option Explicit
    2.  
    3. Private Type Picture_Type
    4.  
    5.     Size As Long
    6.     Width As Long
    7.     Height As Long
    8.  
    9. End Type
    10.  
    11. Private Sub Command1_Click()
    12.    
    13.     Dim Pic(1) As Picture_Type
    14.    
    15.     Dim X As Long, Y As Long
    16.    
    17.     Dim Is_The_Same As Long
    18.    
    19.     Dim Comparison As Single
    20.    
    21.     With Picture1
    22.        
    23.         .BorderStyle = False
    24.         .Picture = LoadPicture("C:\Jacob's Stuff\Pics\Alice.jpg")
    25.         .AutoSize = True
    26.         .AutoRedraw = True
    27.         .ScaleMode = 3
    28.            
    29.     End With
    30.    
    31.     With Picture2
    32.        
    33.         .BorderStyle = False
    34.         .Picture = LoadPicture("C:\Jacob's Stuff\Pics\whiterabbit.jpg")
    35.         .AutoSize = True
    36.         .AutoRedraw = True
    37.         .ScaleMode = 3
    38.        
    39.     End With
    40.    
    41.     With Pic(0)
    42.    
    43.         .Size = Picture1.ScaleWidth * Picture1.ScaleHeight
    44.         .Width = Picture1.ScaleWidth
    45.         .Height = Picture1.ScaleHeight
    46.            
    47.     End With
    48.    
    49.     With Pic(1)
    50.    
    51.         .Size = Picture2.ScaleWidth * Picture1.ScaleHeight
    52.         .Width = Picture2.ScaleWidth
    53.         .Height = Picture2.ScaleHeight
    54.            
    55.     End With
    56.    
    57.     If Pic(0).Size = Pic(1).Size Then
    58.    
    59.         For Y = 0 To Pic(0).Height - 1
    60.        
    61.             For X = 0 To Pic(0).Width - 1
    62.            
    63.                 If Picture1.Point(X, Y) = Picture2.Point(X, Y) Then
    64.                
    65.                     Is_The_Same = Is_The_Same + 1
    66.                
    67.                 End If
    68.            
    69.             Next X
    70.            
    71.         Next Y
    72.        
    73.         Comparison = (Is_The_Same / Pic(0).Size) * 100
    74.        
    75.         MsgBox "Both images are " & Comparison  & "% the same", vbInformation
    76.    
    77.     Else
    78.    
    79.         MsgBox "The pictures are not the same size, so no comparison will be made.", vbCritical
    80.    
    81.     End If

    That's funny. Deja Vu

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Image Comparison

    Well, sure, if they're the same size, and color depth, then you could. You could also mask them both to get a more accurate view. In the other thread they said that the images were different sizes.

  5. #5

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Re: Image Comparison

    Thanks RhinO
    but i want to compare two pictures in very real sense.
    like
    Picture is same ...
    but One is coloured
    and other is Black & White ..
    So when i will compare program should say that pictures LOOK TO BE SAME
    I do not want to compare COLORS only ....

  6. #6
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Image Comparison

    Rhino?

  7. #7
    Addicted Member Max_aka_NOBODY's Avatar
    Join Date
    Jul 2004
    Location
    Amman, Jordan
    Posts
    179

    Re: Image Comparison

    I'd like to mention that if the image was offsetted by as much as one pixel, Jake's approach will likely say it's very different(especially if JPG, since the actual pixels aren't the same even if they were before compression).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width