473,399 Members | 3,656 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,399 software developers and data experts.

Defining and comparing Images?

Hi all,

I'm doing a little project (big for me because I'm pretty much a noob). I have this soltaire game and when a card is captured. I want that card to be colored with a blue background. In other words, that its been played.

How would you go about comparing 1 card say the ace of spades to that same card in another picturebox? Meaning The card is capture in one picturebox and the other picturebox will turn a certain color, making it disappear.

My pseudo code is something like this:
If pictbox1 = pictbox2 Then
color that pictbox2 to blue
Else leave it visible
End IF

So the real problem is how do I compare images and define them, like a .bmp to the same image as in ,say pictbox2.

Could I find a specific hex color on the card and then the card in pictbox2 disappears. How would you define hex color and how would you analzye it?

Sorry for the many questions. If you have a question I can clear it up for you.

Thanks

PS working with vb.net 2005
Jul 13 '07 #1
14 2612
hariharanmca
1,977 1GB
Hi all,

I'm doing a little project (big for me because I'm pretty much a noob). I have this soltaire game and when a card is captured. I want that card to be colored with a blue background. In other words, that its been played.

How would you go about comparing 1 card say the ace of spades to that same card in another picturebox? Meaning The card is capture in one picturebox and the other picturebox will turn a certain color, making it disappear.

My pseudo code is something like this:
If pictbox1 = pictbox2 Then
color that pictbox2 to blue
Else leave it visible
End IF

So the real problem is how do I compare images and define them, like a .bmp to the same image as in ,say pictbox2.

Could I find a specific hex color on the card and then the card in pictbox2 disappears. How would you define hex color and how would you analzye it?

Sorry for the many questions. If you have a question I can clear it up for you.

Thanks

PS working with vb.net 2005

I think your problem is pretty complicated


which Database you are using?

use control array and diff pic in that
Jul 13 '07 #2
I'm not using a database. I think I need to research more on visual basics. This is over my head. I started about a month ago so maybe I can refine my questions with more research and studying.

Thanks for the reply
Jul 13 '07 #3
hariharanmca
1,977 1GB
I'm not using a database. I think I need to research more on visual basics. This is over my head. I started about a month ago so maybe I can refine my questions with more research and studying.

Thanks for the reply

is your project is an playing cards
Jul 13 '07 #4
No its not making a card game..its basically a cardcounter. Really I need to know how to compare .bmp. Or images. Like what API do I call or methods?

I looked around the net and have not came to a tutorial on this, however I came to things that are similiar in nature of what I want to do. It's just not clicking, and maybe some one could throw out some ideas on how these can be achieved. Namely, comparing images to other images.

Moreover the game is already made.
Thanks
Jul 14 '07 #5
hariharanmca
1,977 1GB
No its not making a card game..its basically a cardcounter. Really I need to know how to compare .bmp. Or images. Like what API do I call or methods?

I looked around the net and have not came to a tutorial on this, however I came to things that are similiar in nature of what I want to do. It's just not clicking, and maybe some one could throw out some ideas on how these can be achieved. Namely, comparing images to other images.

Moreover the game is already made.
Thanks

Image or picture controls are basically to display purpose only.

If you want to compare there may be two ways

1. Give different names or each image which you are going to compare.
2. Give different path or each image which you are going to compare.
Jul 14 '07 #6
I think comparing images is not the way to go here. As suggested above, I think you need to define unique names for each card and associate the names with the proper images, possibly using an array or collection. Then you need to have your code keep track of which cards played. I don't use .Net so I can't suggest the best method there. In VB6, I'd play with something like - assuming you have 52 card images 0-51:

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Private Type Card
  4.  
  5. cName As String
  6. cFace As String
  7. cPlayed As Boolean
  8.  
  9. End Type
  10.  
  11. Private Sub cmd_Click()
  12. CreateDeck
  13. End Sub
  14.  
  15. Private Sub CreateDeck()
  16.  
  17. Dim Deck(51) As Card
  18. Dim intSuit As Integer
  19. Dim intCard As Integer
  20. Dim intValue As Integer
  21. Dim intFace As Integer
  22. Dim strFaces(51) As String
  23. Dim CardValue()
  24. Dim CardSuit()
  25.  
  26. CardSuit = Array("Hearts", "Diamonds", "Clubs", "Spades")
  27. CardValue = Array("Ace", "Two", "Three", "Four", "Five", "Six", _
  28. "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King")
  29.  
  30. intCard = 0
  31.  
  32.     For intFace = 0 To 51
  33.         strFaces(intFace) = "E:\Temp\Cards\" & intFace & ".gif"
  34.     Next intFace
  35.  
  36.     For intSuit = 0 To 3
  37.         For intValue = 0 To 12
  38.             Deck(intCard).cName = CardValue(intValue) & " of " & CardSuit(intSuit)
  39.             Deck(intCard).cFace = strFaces(intCard)
  40.             Deck(intCard).cPlayed = False
  41.             intCard = intCard + 1
  42.         Next intValue
  43.     Next intSuit
  44.  
  45. End Sub
  46.  
  47. Private Sub Method_1()
  48. '---------------------------------------------------
  49. 'Using type variables
  50.  
  51. Dim ThisCard As Card
  52. Dim ThatCard As Card
  53.  
  54. ThisCard = Deck(0)
  55. ThatCard = Deck(51)
  56.  
  57. picCard1.Picture = LoadPicture(ThisCard.cFace)
  58. ThisCard.cPlayed = True
  59. MsgBox ThisCard.cName & " Played"
  60.  
  61. ThatCard = Deck(51)
  62. picCard2.Picture = LoadPicture(ThatCard.cFace)
  63.  
  64.     If ThatCard.cPlayed = True Then
  65.         picCard2.Picture = Nothing
  66.     End If
  67.  
  68. End Sub
  69.  
  70. Private Sub method_2()
  71. '---------------------------------------------------
  72. 'Using array subscript directly and tag property of PictureBox
  73. picCard1.Picture = LoadPicture(Deck(0).cFace)
  74. picCard1.Tag = 0
  75. MsgBox Deck(0).cName & " Played"
  76.  
  77. picCard2.Picture = LoadPicture(Deck(51).cFace)
  78. picCard1.Tag = 51
  79.  
  80.     If picCard2.Tag = picCard1.Tag Then
  81.         picCard2.Picture = Nothing
  82.     End If
  83.  
  84. End Sub
  85.  
That may be overly complex - all you really need is an array of 52 cards with the images and refer to the array subscript. That's my general idea. If you have an array of picturebox controls, you can easily load card(1) into pic(1), etc. You can use another array of booleans to track which cards have been played if you need that. Just keep track of which card is displayed where and that should do it. Comparing the actual bitmaps would be difficult and IMO unnecessary here.

An even better solution would be to use the cards.dll that Windows Solitare uses - there's a tutorial here:

http://www.codeproject.com/csharp/drawcardscp1.asp

It's in C# though, maybe you can find a VB.Net version. The dll does a lot of the work of drawing and moving cards for you but I don't know if it tracks the play - you may still have to do that yourself.

Heres a VB6 version:http://www.catch22.net/tuts/cardtut.asp with an example. Search around, there are probably several example card games in VB that may give you some ideas also.
Jul 16 '07 #7
hariharanmca
1,977 1GB
Yes, I too think about that, but he told it’s not a card game. Refer thread #4 and #5. I think he mean, to refer images directly
Jul 16 '07 #8
Killer42
8,435 Expert 8TB
Yes, I too think about that, but he told it’s not a card game. Refer thread #4 and #5. I think he mean, to refer images directly
The point is, you should be comparing the values which are represented by the images - not the images themselves. Comparing images is a very "expensive" process. The images should be seen as simply a visual indication of what value is being manipulated in the program.
Jul 17 '07 #9
hariharanmca
1,977 1GB
The point is, you should be comparing the values which are represented by the images - not the images themselves. Comparing images is a very "expensive" process. The images should be seen as simply a visual indication of what value is being manipulated in the program.
Comparing images is a very "expensive" process.


My head is triggering a question. Is it possible to compare images (not with the reference of Image path or Image Name) through VB? (It’s not urgent. But looking for at least hints).
Jul 17 '07 #10
Killer42
8,435 Expert 8TB
My head is triggering a question. Is it possible to compare images (not with the reference of Image path or Image Name) through VB? (It’s not urgent. But looking for at least hints).
The short answer is "yes". The longer answer is "yes, but how depends on what you mean".

For instance, you could say If Picture1.Picture = Picture2.Picture - this will tell you whether they are references to the same image. I don't recall the technical terminology, but it involves handles and device contexts and stuff like that. This will work in many cases, quite possibly including the one raised here by the OP.

On the other hand, if you like, you can certainly loop through and compare the images pixel by pixel to see whether they are identical. I have actually written an image comparison utility, many years ago, which I had planned to release as shareware. So despite a poor memory, I do have some idea what I'm talking about.

You could even go further and do pattern recognition to try and determine whether images are of the same subject - but that's way out of my league.
Jul 17 '07 #11
hariharanmca
1,977 1GB
The short answer is "yes". The longer answer is "yes, but how depends on what you mean".

On the other hand, if you like, you can certainly loop through and compare the images pixel by pixel to see whether they are identical. I have actually written an image comparison utility, many years ago, which I had planned to release as shareware. So despite a poor memory, I do have some idea what I'm talking about.

You could even go further and do pattern recognition to try and determine whether images are of the same subject - but that's way out of my league.
thank you for such grate hints and good luck to get more money to release your shareware.

all the best
Jul 17 '07 #12
I was talking to a programmer the other day but he had to go. He said the way he did image comparison was with GETPIXEL. He gave me snippet , however, I kind of clueless on what it means. Could anyone elaborate on this:

Expand|Select|Wrap|Line Numbers
  1. dim clr as color
  2. clr = getpixel(x,y)
  3. debug.print(clr.tostring)
Thanks
Aug 1 '07 #13
hariharanmca
1,977 1GB
I was talking to a programmer the other day but he had to go. He said the way he did image comparison was with GETPIXEL. He gave me snippet , however, I kind of clueless on what it means. Could anyone elaborate on this:

dim clr as color
clr = getpixel(x,y)
debug.print(clr.tostring)

Thanks
this is what it means.

Expand|Select|Wrap|Line Numbers
  1. dim clr as color
  2. 'Declaring clr as Color
  3. clr = getpixel(x,y)
  4. 'assigening clr value(pixel) in X and Y axis through getpixel
  5. debug.print(clr.tostring)
  6. 'Convert clr to string and Printing it in debug editor
Aug 1 '07 #14
Killer42
8,435 Expert 8TB

dim clr as color
...
debug.print(clr.tostring)
What is this, VB.Net?
Aug 1 '07 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Michael Rostkowski | last post by:
I posted this in alt.php, but as a reply, so now I'm posting it here for people who might have missed it but still could find it useful. Thanks to Andy Hassall for giving me good information. ...
10
by: Andy B | last post by:
Hi, I am very new to JavaScript and my first assignment is to create a simple game. Below is my code which works fine in IE, but not in any other browser (Opera, Netscape, Mozilla). It has no form...
3
by: Robert Dell | last post by:
I have a problem comparing strings in an order form i'm writing. I want to give a running total at the bottom of the page and it appears to be working except it doesn't compare correctly (it...
1
by: - Steve - | last post by:
I've assigned three pictures as resources. So I can access them via Resources.Image1, Resources.Image2, etc On the buttons I try to do the following if(Button1.Image == Resources.Image1) ...
1
by: Adam Dockter | last post by:
I have a couple questions about comparing images. I notice the imagelist collection of images doesn't provide any comparison of images, and the System.Drawing.Image.Equal function will not compare...
3
by: Solitus | last post by:
Lets say i have 2 images, a.jpg and b.jpg Both are actually one same picture of a bear but have different filenames. is there anyway in .net that i can find out if the two pictures are actually...
2
by: Helpful person | last post by:
I wish to access several pictures on my page by defining them as an array. This way I can either loop through them or access them by array index. I am a beginner at Javascript so please keep...
6
by: lanwrangler | last post by:
I know it's a long shot but does anyone have any pointers to generic algorithms - or, even better, Python code - for comparing images and computing a value for the "difference" between them? ...
0
by: anchal25 | last post by:
Hi, I am new to this forum and have found out some image comparison algorithms here. But my requirement is to compare two images which are similar but different in size. First I tried to resize...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
0
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...

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.