473,396 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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(img2) Then
MsgBox("ok!")
Else
MsgBox("wrong!")
End If
Jun 30 '06 #1
3 3832
> 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 ImgCheckSameSize(byval ImageA as image , ImageB as image )
as boolean

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

regards

Michel Posseth [MCP]

"Saber" <saber[.AT.]oxin.ir> schreef in bericht
news:%2****************@TK2MSFTNGP03.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(img2) 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(img2) 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.comwrote in message
news:ud*************@TK2MSFTNGP05.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 ImgCheckSameSize(byval ImageA as image , ImageB as
image ) as boolean

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

regards

Michel Posseth [MCP]

"Saber" <saber[.AT.]oxin.irschreef in bericht
news:%2****************@TK2MSFTNGP03.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(img2) 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
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
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...
8
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...
3
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
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...
6
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...
6
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.