Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

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

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
Lukie Luke
Asked:
Lukie Luke
  • 6
  • 5
1 Solution
 
aikimarkCommented:
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
 
Lukie LukeAuthor Commented:
Can you specify the code ? Thank you in advance :)
0
 
aikimarkCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Lukie LukeAuthor Commented:
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
 
aikimarkCommented:
@Lukie Luke

please read, edit the project and upload it again
Is this your program?
Do you know how to program?
0
 
Lukie LukeAuthor Commented:
I'm new to VB. I found it from vbforum
0
 
aikimarkCommented:
Do you know how to program in any language?
0
 
Lukie LukeAuthor Commented:
@aikimark Yes, I know a bit of programing in Visual Basic 6.0
0
 
aikimarkCommented:
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
 
Lukie LukeAuthor Commented:
Thank you, sir
0
 
PortletPaulCommented:
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
 
Lukie LukeAuthor Commented:
Thank you sir for the advise :)
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now