counting a number of pixels together 'an object' with a certain color on screen

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
maxkill
Posts: 158
Joined: 11 Apr 2016, 13:03

counting a number of pixels together 'an object' with a certain color on screen

Post by maxkill » 28 Jan 2023, 19:00

Hello, I would like to count for example numbers of arrows on the screen of a certain color (not appearing anywhere else). Any quick way to fix such a counter? Preferrably bind the counting to a key.


maxkill
Posts: 158
Joined: 11 Apr 2016, 13:03

Re: counting a number of pixels together 'an object' with a certain color on screen

Post by maxkill » 28 Jan 2023, 20:16

mikeyww wrote:
28 Jan 2023, 19:41
Here are some ideas for you: viewtopic.php?p=391569#p391569

Good luck!
That searches for images which is similar to my other thread which didn't work. Is there no easy way to just search for these same colored pixels that stick together occuring in different spots on the screen and count them? One would think ahk could handle that easy some way :idea: :?:


maxkill
Posts: 158
Joined: 11 Apr 2016, 13:03

Re: counting a number of pixels together 'an object' with a certain color on screen

Post by maxkill » 28 Jan 2023, 20:54

mikeyww wrote:
28 Jan 2023, 20:35
How about a :arrow: PixelSearch :?:
I know how to make pixelsearches and move mouse to the found color but not to look for several pixels together and to count them .. :eh:

User avatar
mikeyww
Posts: 26951
Joined: 09 Sep 2014, 18:38

Re: counting a number of pixels together 'an object' with a certain color on screen

Post by mikeyww » 28 Jan 2023, 21:25

You can find one pixel and then search the neighboring ones. I don't know why that is easier than searching for an image, but it may depend on the specific pixels.

maxkill
Posts: 158
Joined: 11 Apr 2016, 13:03

Re: counting a number of pixels together 'an object' with a certain color on screen

Post by maxkill » 29 Jan 2023, 19:49

mikeyww wrote:
28 Jan 2023, 21:25
You can find one pixel and then search the neighboring ones. I don't know why that is easier than searching for an image, but it may depend on the specific pixels.
not sure how to fix that script, but yes sounds nice

User avatar
mikeyww
Posts: 26951
Joined: 09 Sep 2014, 18:38

Re: counting a number of pixels together 'an object' with a certain color on screen

Post by mikeyww » 29 Jan 2023, 19:58

You would probably write a detailed plain-language description, step by step, of exactly how you identify one of these images yourself when you look at it. You would then translate each step into AutoHotkey.

User avatar
boiler
Posts: 16965
Joined: 21 Dec 2014, 02:44

Re: counting a number of pixels together 'an object' with a certain color on screen

Post by boiler » 29 Jan 2023, 20:24

maxkill wrote: That searches for images which is similar to my other thread which didn't work.
You gave up on your last thread without even following up on the initial feedback after stating you couldn’t make the ImageSearchAll function work. This is very likely easily solved, but you are just describing your group of pixels in words. An example image or two would really clear up what you’re trying to describe and allow the forum members to give specific feedback to fix it.

maxkill wrote: Is there no easy way to just search for these same colored pixels that stick together occuring in different spots on the screen and count them?
What is a group of pixels that stick together if not an image? Maybe the issue is you are thinking ImageSearch can only search for a rectangular reference image and aren’t aware that by applying ImageSearch’s *TransN option, you can search for any irregular and even non-contiguous shape. Basically, it can find any group of pixels in a known pattern.

iseahound
Posts: 1445
Joined: 13 Aug 2016, 21:04
Contact:

Re: counting a number of pixels together 'an object' with a certain color on screen

Post by iseahound » 30 Jan 2023, 10:29

You can play around with this:

viewtopic.php?f=6&t=111773

It's useful for debugging ImageSearch. You can use any ImageSearch function you'd like.

maxkill
Posts: 158
Joined: 11 Apr 2016, 13:03

Re: counting a number of pixels together 'an object' with a certain color on screen

Post by maxkill » 01 Feb 2023, 21:37

boiler wrote:
29 Jan 2023, 20:24
-
mikeyww wrote:
29 Jan 2023, 19:58
-
iseahound wrote:
30 Jan 2023, 10:29
-
too hard, can't do it

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: counting a number of pixels together 'an object' with a certain color on screen

Post by swagfag » 02 Feb 2023, 00:14

if u cant do it, dont post vague descriptions of ur problem, implying that u can do it urself

do as boiler says and describe everything that it relevant. what game, what ure trying to match, with screenshots

it could be that imagesearch doesnt even work on that particular game(last i checked Path of exile comes to mind)

malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: counting a number of pixels together 'an object' with a certain color on screen

Post by malcev » 02 Feb 2023, 00:43

maxkill, may be it is better for Your task to use opencv.
You can google examples of shape detection in python and then convert code to ahk.
viewtopic.php?t=96394

wer
Posts: 57
Joined: 29 Nov 2022, 21:28

Re: counting a number of pixels together 'an object' with a certain color on screen

Post by wer » 02 Feb 2023, 06:18

is your "arrows" all have the same size and shape?
may be we could say those look like "→"
if so, maybe you can split the screen to many smaller areas, depend on your need
then use pixelsearch these areas one by one, with x y offsets
once you got the matched coordinate on the most left of "→"
you can further check the pixel on most right whether or not "certain color"
in this case, the offset of x depend on the length of "→", right?
of cause this way is not 100 precent exact, thats why imagesearch is better...
i think this is what mikeyww try to tell you

Post Reply

Return to “Ask for Help (v1)”