Solved

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

Posted on 2014-07-29
12
199 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

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 49

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

705 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