Folks, is it possible to search (via imagesearch or by another method) for an object that is not rectangular?
The screen is full of tiles of different colors. On each tile, there is an icon. There are a variety of six icons of different, irregular shapes and about six colors also, and I would like to find their locations irrespective of what color of tile they are on. As an example, I would like to search for a green hand, whether it is on a light blue, dark blue, red, green or yellow tile. Both the icons and the tiles are complex - not just flat colors in an outline. They have reflections, showing raised edges, etc. Sometimes, an icon can be on a tile of its own color (but the icon is visible because of its outline). Sometimes, the tiles are square, but sometimes, they are triangular, so looking for an image of a green icon on a red tile is not possible, because adjacent tiles would have different colors, and would be included in an upright, rectangular search image. The context of the screen simply does not lend itself to an imagesearch, as the image being searched for would contain parts of the color of the background tile, or parts of colors of adjacent tiles.
So the question is - is it possible to search for an irregular shape?
Imagesearch a non-rectangular object
Re: Imagesearch a non-rectangular object
Use the *Trans option of ImageSearch to ignore certain color pixels in your reference Image. For example, use the option *TransBlack, then use MS Paint to black out all the pixels that may change and/or you want to ignore, leaving it any shape object you make it (the non-black pixels).
Re: Imagesearch a non-rectangular object
Thanks very much. That seems a plan!
I'll give it a go.
I'll give it a go.
- FanaticGuru
- Posts: 1906
- Joined: 30 Sep 2013, 22:25
Re: Imagesearch a non-rectangular object
Many times you don't have to search for a whole icon especially if the icons are complex. Just find a small square in the icon that does not change and search for that.colmik wrote:Folks, is it possible to search (via imagesearch or by another method) for an object that is not rectangular?
The screen is full of tiles of different colors. On each tile, there is an icon. There are a variety of six icons of different, irregular shapes and about six colors also, and I would like to find their locations irrespective of what color of tile they are on. As an example, I would like to search for a green hand, whether it is on a light blue, dark blue, red, green or yellow tile. Both the icons and the tiles are complex - not just flat colors in an outline. They have reflections, showing raised edges, etc. Sometimes, an icon can be on a tile of its own color (but the icon is visible because of its outline). Sometimes, the tiles are square, but sometimes, they are triangular, so looking for an image of a green icon on a red tile is not possible, because adjacent tiles would have different colors, and would be included in an upright, rectangular search image. The context of the screen simply does not lend itself to an imagesearch, as the image being searched for would contain parts of the color of the background tile, or parts of colors of adjacent tiles.
So the question is - is it possible to search for an irregular shape?
This is not complex but for example searching for this
Just pick a 8x8 pixel square in the middle that includes no background, which might only include its eyes and mouth but if they are unique then you can just search for that small part of the icon.
That is pretty much what I always do. Just search for the smallest distinctive part of an image that I want to find. That often avoids the problem of eye candy borders with reflections and sparkles that are dynamic if you can find a small piece that is static to search for.
FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
Re: Imagesearch a non-rectangular object
FanaticGuru, thanks for that. Your method is good, and I believe also results in a faster search. I have used it many times in the past - but it didn't apply here. I couldn't find a unique part of the icon that did not also appear on a tile of the same color. However, I have done some experiments with TransBlack, and it's looking hopeful.