473,654 Members | 3,104 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to find equal images?

There are some Images (System.Drawing .Image) with same widths and heights,
I want to find if 2 images are equal.
How can I do it?

The following code always returns false:

If img1.Equals(img 2) Then
MsgBox("ok!")
Else
MsgBox("wrong!" )
End If
Jun 30 '06 #1
3 3840
> The following code always returns false:

yes because you are checking if the 2 pictures are identical not only in
size but also as image , if there is one bit different set it will return
false although you might not see it with the naked eye
but what you want checking the size can you easily do with a custom function

< not behind my dev pc modus so check for typo`s >

private function ImgCheckSameSiz e(byval ImageA as image , ImageB as image )
as boolean

if (ImageA.Width = ImageB.Width) AndAlso ( ImageA.Height=I mageB.Height)
then
return true
end if
end function

regards

Michel Posseth [MCP]

"Saber" <saber[.AT.]oxin.ir> schreef in bericht
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
There are some Images (System.Drawing .Image) with same widths and heights,
I want to find if 2 images are equal.
How can I do it?

The following code always returns false:

If img1.Equals(img 2) Then
MsgBox("ok!")
Else
MsgBox("wrong!" )
End If

Jul 1 '06 #2
Saber wrote:
There are some Images (System.Drawing .Image) with same widths and
heights, I want to find if 2 images are equal.
How can I do it?

The following code always returns false:

If img1.Equals(img 2) Then
MsgBox("ok!")
Else
MsgBox("wrong!" )
End If
See the help for for System.Drawing. Image.Equals - what it's testing for is
if img1 and img2 point to the same object.

If this is some sort of image-matching game (like
http://en.wikipedia.org/wiki/Concentration_%28game%29) then it will probably
be much better to get the computer to remember which images are the same
instead of comparing them pixel-by-pixel.

Iterating over two images and comparing each value from
System.Drawing. Bitmap.GetPixel could be slow. I suspect there's a quicker
way not using the .net framework. Google could be your friend.

Andrew
Jul 3 '06 #3
Michel,
I don't want checking the size, as I said, the size of images are exactly
equal,
and the Equals method of Object *always* returns false even when I get the
images from "one" image file.

I think I've to do Andrew's solution and compare the images pixel by pixel.

Thanks

"Michel Posseth [MCP]" <MS**@posseth.c omwrote in message
news:ud******** *****@TK2MSFTNG P05.phx.gbl...
>The following code always returns false:

yes because you are checking if the 2 pictures are identical not only in
size but also as image , if there is one bit different set it will return
false although you might not see it with the naked eye
but what you want checking the size can you easily do with a custom
function

< not behind my dev pc modus so check for typo`s >

private function ImgCheckSameSiz e(byval ImageA as image , ImageB as
image ) as boolean

if (ImageA.Width = ImageB.Width) AndAlso ( ImageA.Height=I mageB.Height)
then
return true
end if
end function

regards

Michel Posseth [MCP]

"Saber" <saber[.AT.]oxin.irschreef in bericht
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
>There are some Images (System.Drawing .Image) with same widths and
heights,
I want to find if 2 images are equal.
How can I do it?

The following code always returns false:

If img1.Equals(img 2) Then
MsgBox("ok!")
Else
MsgBox("wrong!" )
End If



Jul 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1548
by: Gram | last post by:
Hello, Using ASP, can all the images in a file be listed, so I can then get ASP to determine the combined size of these files to give an estimate of load time? Thanks for any help Gram.
22
3100
by: Fabian | last post by:
var preload1 = new Image(); preload1.src = "/pic/yay.gif"; var preload2 = new Image(); preload2.src = "/pic/nay.gif"; The above is meant to preload image files, yes? Problem is, it doesnt seem to be doing so in practice. Any idea where Im going wrong? Could it be that things work differnetly when in an attached .js file? -- --
8
1899
by: Mad Scientist Jr | last post by:
Has anyone worked with code that can look at two JPG images (I am talking about relatively small ones, 40x40 pixels or less) and quickly analyzing them to see how similar or different they are? Is bitmap comparison supported by .net's graphics libraries? Initially I could compare JPG or BMP file size to see if the images are different, but I would like the code to be able to discern HOW different two images are - ie image A and B are 50%...
3
973
by: El Camino | last post by:
Lets say i have : intID=1 I need to switch that integer to 'A' If i have intID=2 then need to switch to 'B' If i have intID=3 then need to switch to 'C'
15
4464
by: Thomas W | last post by:
How can I use python to find images that looks quite similar? Thought I'd scale the images down to 32x32 and convert it to use a standard palette of 256 colors then compare the result pixel for pixel etc, but it seems as if this would take a very long time to do when processing lots of images. Any hint/clue on this subject would be appreciated. Best regards, Thomas
6
3504
by: NutsAboutVB | last post by:
Hello, I am a .NET programmer and I have a JPEG image file (from digital camera) of about 109 KB's in size, when I open it and save it (without making any alterations at all, just going to File --> Save) in MS Photo Editor, the file is automatically shrunk in size to 81 KB's. When doing the same thing in MS Paint, the file is shrunk to 54 KB's. The file has the same number of pixels after both saves (as expected). My question follows...
6
1901
by: LP | last post by:
Hi there, Sorry if this is a little off-topic here but can anyone explain why, when I launch my website from within VS, it can find my image files ok when they're in the root like so: <img src="Test.jpg"> <img src="http://localhost:3932/WebSite/Test.jpg"> but can't find them in "App_Data" if I try either of the following instead
0
8294
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8709
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7309
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5627
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4297
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2719
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1597
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.