Solved

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

Posted on 2014-07-29
12
197 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA filters 2 81
How to read File Date Created using VB6 8 70
Dinamic report to Crosstab query 9 59
Userform to show a range in excel. 3 31
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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

739 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