 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Dixon
Joined: 20 Jan 2005 Posts: 28
|
Posted: Wed Mar 09, 2005 2:42 pm Post subject: Image Search question |
|
|
Im having some trouble getting image search to do what I want. Basically search for a small 3x3 pixel image in a 100x100 px area.
It seems that the "shade" of the image causes it to fail in my setup. sometimes the icon will be dimmer than others and it will miss it if not exact.
With Pixel Search you can specify a "variance" to compensate for this. Would it be possible to do something like this with image search?
Just a question that I dont know the answer to and thought I would ask
Rajat, you mentioned in a post earlier that you had written a 2x2 matrix search function when image search didnt fit your project. Mind sharing that with us? That could work as a substitute in this case I think.
Thank you for any help  |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10474
|
Posted: Wed Mar 09, 2005 3:23 pm Post subject: Re: Image Search question |
|
|
| Dixon wrote: | | With Pixel Search you can specify a "variance" to compensate for this. Would it be possible to do something like this with image search? | It sounds like a good idea; I'll add it to the to-do list. I'll also forward this topic on to the author of ImageSearch in case he has any thoughts about it. Edit: This feature has been added.
It might be a while in coming, so in the meantime, you might want to use PixelSearch to identify two or three distinguishing pixels within the target image. In other words, use PixelSearch in a loop to find the image.
Alternatively, you could try converting the passing in a GIF file for the ImageFile parameter. If that doesn't help the image get found, you could also try calling ImageSearch once for each of a series of variants of the image.
Last edited by Chris on Thu Aug 18, 2005 11:26 am; edited 1 time in total |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Wed Mar 09, 2005 4:15 pm Post subject: |
|
|
Might be of topic ...
| Quote: | giftab is a tiny utility that I wrote that changes the color table entries in a GIF file. It was written to be used at a Unix command prompt, and has been tested on OpenBSD and Linux. There should be no difficulty porting it to other platforms, and I suspect in many cases it will build without any modification.
This program is pretty simple and hardly worth being here at all. It exists because I wanted to make it easy to change the color scheme of my website without having to modify all the images individually. What giftab does is use the index provided as an entry into the color table, which starts at an offset of 13 in a GIF file. Individual entries are three bytes apart
giftab index_number color [index_number color ...] filename
The index_number is a value from 0-255 that represents which table entry to change. color is an HTML formated color code that specifies the new color. Note, that while it is possible to use a octothorpe (#, also known as a pound sign) to prefix the color code, it will have to be encased in quotations to prevent the shell from interpreting the rest of the line as a comment.
The filename is simply the name of the GIF file that is to be worked upon. Note that no special GIF file sanity checking is performed.
[More... + Source] |
|
|
| Back to top |
|
 |
Dixon
Joined: 20 Jan 2005 Posts: 28
|
Posted: Wed Mar 09, 2005 7:00 pm Post subject: |
|
|
Thanks for the replies you 2 The community here is so helpful. I have been working on something to try and check a few pixels in a recatangle area and I think im close but no cookies!
If anyone can take a look at this and tell me what I am missing I would appreciate it. Part of this code was taken from the Zoom Script thats on the script forum and shredded to pieces by me. The rest was out of the ahk helpfile. Im so good at copy and paste I scare myself at times
| Code: |
;================================================================================
; Make a color array of the pixels found
^!1::
RangeX = -5,0,5
RangeY = -5,0,5
MouseGetPos, X, Y
MouseMove, 10, 10
Sleep, 500
Loopcount = 0
Loop Parse, RangeY, CSV
{
ParseY = %A_LoopField%
Loop Parse, RangeX, CSV
{
Loopcount += 1
ParseX = %A_LoopField%
PixelGetColor, PixelColor%LoopCount%, (X + ParseX), (Y + ParseY)
}
}
Return
;================================================================================
; EXPERIMENTAL PIXEL SEARCHING!
^!2::
PixelsFound = 0 ; Reset our pixelcount!
loop
{
ColorArray := PixelColor%a_index%
if ColorArray = ; Blank item encountered, so this is the end of the array.
break
PixelSearch, FCX, FCY, 500, 500, 505, 505, %ColorArray%, 2, Fast
if ErrorLevel = 0
{
PixelsFound += 1
if PixelsFound >= 7 ; found 7 out of 9 pixels found is good enough
{
MsgBox, I found %ColorArray% it is number %PixelsFound% out of %LoopCount%
}
}
}
Return
;================================================================================ |
|
|
| Back to top |
|
 |
Rajat
Joined: 28 Mar 2004 Posts: 1718
|
Posted: Thu Mar 10, 2005 6:47 am Post subject: |
|
|
| Quote: | Rajat, you mentioned in a post earlier that you had written a 2x2 matrix search function when image search didnt fit your project. Mind sharing that with us? That could work as a substitute in this case I think.
|
oh that script is still left inbetween i was working on something else... actually i spent last couple of days writing a LAN battleships game for my office ... its just last night that i got proper sleep!  _________________
 |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|