Solved

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

Posted on 2014-07-29
12
191 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
ID: 40227253
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
ID: 40227300
Can you specify the code ? Thank you in advance :)
0
 
LVL 45

Expert Comment

by:aikimark
ID: 40227356
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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

Author Comment

by:Lukie Luke
ID: 40228257
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
ID: 40228289
@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
ID: 40228293
I'm new to VB. I found it from vbforum
0
 
LVL 45

Expert Comment

by:aikimark
ID: 40228295
Do you know how to program in any language?
0
 

Author Comment

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

Accepted Solution

by:
aikimark earned 500 total points
ID: 40228358
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
ID: 40228372
Thank you, sir
0
 
LVL 48

Expert Comment

by:PortletPaul
ID: 40228379
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
ID: 40229295
Thank you sir for the advise :)
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Vb.net 2008 2 59
VBA color chart bars 12 86
VBA open file from excel cell 4 42
Prevent user closing word document opened with VB6 6 74
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

773 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