Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Pixel Search instead of Image search


  • Please log in to reply
5 replies to this topic
SkrillexAkaCraft
  • Members
  • 45 posts
  • Last active: Jan 04 2018 06:02 PM
  • Joined: 04 Feb 2015

So i'm trieng to make a pixelsearch function instead of a imagesearch function due having problems

 

 

 

so what i'm trieng to do is get a pixex from the coordinates of this 

 

21cf881.png

 

 

 

 

 

 

 

 

 

what i got is this 

; Function:                             detect_cought()
    ; Description:                          Checks if battle sequence has begun
    ;
     detect_cought(){
    CoordMode, Pixel, Screen
        Loop
        {
         PixelSearch, X, Y, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%
            if (ErrorLevel=0)
        {
            return, 1
        }
        else
        {
            return, 0
        }
    }
}
 
what i used before is this
 

 ;Function:                             detect_window()
    ; Description:                          Checks if battle sequence has begun
    ;
     
     detect_window(){
        ImageSearch barrowx, barrowy, 0, 0, 1920, 1080, *25 Lib/cought.png
            if (ErrorLevel=0)
        {
            return, 1
        }
        else
        {
            return, 0
        }
    }
 
 
but due the image being to small it didnt work
 
 
mila2t.jpg

 



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

Smaller images tend to work best. Do you know for sure it was due to the image being too small? I made the variation *125 instead and was able to find the pokeball on screen (but only against a dark background it seems); I verified it was not a false positive by having it move the mouse to the pokeball.

 

What I've found to work with ImageSearch is to trim the border of the image away in an image editing program (MS Paint before Windows 10 I believe is incapable of doing this well, but I might be wrong; you need to have it set a transparent background; I recommend Paint.NET, others recommend GIMP as free alternatives.)

 

However, as for your PixelSearch problems, you never specified a color. And you're still searching the entire screen. I'd imagine you'd just want to search for a red pixel found inside the pokeball region. Use an image editor or WindowSpy to identify that color, and then also use WindowSpy to identify the area that the pokeball icon can appear in. You don't want to search the entire screen because it is possible there's a matching red pixel elsewhere on the screen.



SkrillexAkaCraft
  • Members
  • 45 posts
  • Last active: Jan 04 2018 06:02 PM
  • Joined: 04 Feb 2015

Smaller images tend to work best. Do you know for sure it was due to the image being too small? I made the variation *125 instead and was able to find the pokeball on screen (but only against a dark background it seems); I verified it was not a false positive by having it move the mouse to the pokeball.

 

What I've found to work with ImageSearch is to trim the border of the image away in an image editing program (MS Paint before Windows 10 I believe is incapable of doing this well, but I might be wrong; you need to have it set a transparent background; I recommend Paint.NET, others recommend GIMP as free alternatives.)

 

However, as for your PixelSearch problems, you never specified a color. And you're still searching the entire screen. I'd imagine you'd just want to search for a red pixel found inside the pokeball region. Use an image editor or WindowSpy to identify that color, and then also use WindowSpy to identify the area that the pokeball icon can appear in. You don't want to search the entire screen because it is possible there's a matching red pixel elsewhere on the screen.

i did use photoshop to make the image into png :) can you send me your examples?



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

My example was for finding the Note/Comment icon in a PDF file in Adobe Reader.

 

https://imgur.com/a/DHKi8

 

BWZ0I9g.png This is a snippet of the actual icon in an actual PDF

 

adzo87u.png  This is the image file I would use with ImageSearch. I used a setting in the command to treat the white as transparent. *TransFFFFFF. I totally forgot that *Trans was an option in ImageSearch, which might actually be necessary instead of having an actual transparent background.

 

Notice how I eliminated the black border of the star in the image I used to search with.



SkrillexAkaCraft
  • Members
  • 45 posts
  • Last active: Jan 04 2018 06:02 PM
  • Joined: 04 Feb 2015

My example was for finding the Note/Comment icon in a PDF file in Adobe Reader.

 

https://imgur.com/a/DHKi8

 

BWZ0I9g.png This is a snippet of the actual icon in an actual PDF

 

adzo87u.png  This is the image file I would use with ImageSearch. I used a setting in the command to treat the white as transparent. *TransFFFFFF. I totally forgot that *Trans was an option in ImageSearch, which might actually be necessary instead of having an actual transparent background.

 

Notice how I eliminated the black border of the star in the image I used to search with.

so by removing the border you use a magiceraser or? coz i only use photoshop for my image editin :/



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

I literally took the eraser (or a brush tool to paint a white boarder - one without anti-aliasing) and liberally erased the border. Hypothetically, my image is going to match any block or blob of yellow that is larger than it as it is a single color, but for an image like the pokeball, if you shave off that border and have a much tighter image, it should work.

 

I went ahead and tested it, and here's what I came up with. I used TransColor.

 

http://i.imgur.com/G...Ggvocya.png    Ggvocya.png

 

You can see how tiny that is. Also, it's hard to see against the white background, but there are yellow dots in the corners. I probably could've left the original image in tact at that part, but I put in the yellow dots and used the TransColor with this code:

 

^6::
ImageSearch, x, y, 0, 0, A_ScreenWidth, A_ScreenHeight, *TransFFFF00 pokeball2.png
If !ErrorLevel
  {
  MsgBox Success
  MouseMove, x, y
  }
else
  Msgbox Failure %ErrorLevel%
return

 

I then tested this script on your in-game sample image of the battle and it found the pokeball for me. Also notice that there's no variation in my ImageSearch.