Solved

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

Posted on 2014-07-29
12
193 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

820 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