Solved

[VB6] Compare two images and show percentage that one matches the other ?

Posted on 2014-07-29
12
179 Views
Last Modified: 2014-07-30
I use the GetDIBits() API function to compare two images to tell if they're the same or different much quicker than using GetPixel or other methods. But is there any way to show percentage that one matches the other ? Here is the project
CompareImages.zip
0
Comment
Question by:Lukie Luke
  • 6
  • 5
12 Comments
 
LVL 45

Expert Comment

by:aikimark
Comment Utility
The correct approach for best performance is to populate two arrays as efficiently as possible and then compare the pixel locations.  Count the number of times the pixel values are different and divide by the total number of pixels (=rows*columns)
0
 

Author Comment

by:Lukie Luke
Comment Utility
Can you specify the code ? Thank you in advance :)
0
 
LVL 45

Expert Comment

by:aikimark
Comment Utility
If you are using the API function, you already have the arrays populated.  Nest two For...Next loops, one for the row value and one for the column value.
Example:
For lngRow=0 to ubound(dibarray,1)
   For lngCol=0 to ubound(dibarray,2)
   Next
Next

Open in new window

0
 

Author Comment

by:Lukie Luke
Comment Utility
Sorry I don't want to bother you but please read, edit the project and upload it again. My main problem is to show the percentage between two images. I don't really understand your code.
0
 
LVL 45

Expert Comment

by:aikimark
Comment Utility
@Lukie Luke

please read, edit the project and upload it again
Is this your program?
Do you know how to program?
0
 

Author Comment

by:Lukie Luke
Comment Utility
I'm new to VB. I found it from vbforum
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 45

Expert Comment

by:aikimark
Comment Utility
Do you know how to program in any language?
0
 

Author Comment

by:Lukie Luke
Comment Utility
@aikimark Yes, I know a bit of programing in Visual Basic 6.0
0
 
LVL 45

Accepted Solution

by:
aikimark earned 500 total points
Comment Utility
Then program it and post questions when you get stuck.  I've posted model nested For...Next statements you can pattern your after.

If you want someone to do your work for you, then look at the top VB experts and see if any have enabled their Hire Me button in their profiles.

I found it from vbforum
Alternatively, ask the author of the program you have downloaded.
0
 

Author Comment

by:Lukie Luke
Comment Utility
Thank you, sir
0
 
LVL 48

Expert Comment

by:PortletPaul
Comment Utility
The .bas file in that zip is represented here.

There is a nested loop at the end of that VB code, "Private Function ComparePixels() As Boolean "

If you create a similar function with a nested loop, counting when pixels are true, or false, or both, then you have the basis for a percentage calculation. (nb: if you have the total size to start with then you don't need both but you could do it that way.)

Note the existing function has an "Exit For" escape, so it does not compare all pixels if a difference is found (so it is just determining "different" or "not-different").

ps: I haven't touched VB in a million years (or thereabouts) so I'm not offering more than this
0
 

Author Comment

by:Lukie Luke
Comment Utility
Thank you sir for the advise :)
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now