GetPixelColor -> RGB
Moderators: JRL, Dorian (MJT support)
GetPixelColor -> RGB
My problem ist to check, if a symbol shows up at a specific place in the monitored window. The litte problem is: it has a changing background and it is 20% transparent, so the image recognition fails to check as well as the check for the exact color of certain pixels.
My idea was to check every pixel and calculate a 'range' of color, that matches, but this is difficult, as the getpixelcolor function returns a high range of numbers. To guess my color with the range i'd like to get to this format:
R: X1 +/- x
G: X2 +/- x
B: X3 +/- x
if X1-X3 are integer or hex, i don't mind...
I think the function FindImagePos with the color range does quite a familiar thing, but i can't use this function due to the great chances in the background. Any suggestions?
My idea was to check every pixel and calculate a 'range' of color, that matches, but this is difficult, as the getpixelcolor function returns a high range of numbers. To guess my color with the range i'd like to get to this format:
R: X1 +/- x
G: X2 +/- x
B: X3 +/- x
if X1-X3 are integer or hex, i don't mind...
I think the function FindImagePos with the color range does quite a familiar thing, but i can't use this function due to the great chances in the background. Any suggestions?
Sorry it's AND not OR
Let’s say your high range is 15467 and your low range 13678 what you have to do is add 20 or so to the high range and subtract 20 or so from the low range.
The code would look like this:
GetPixelColor>X,Y,COLOR
IF>{(%COLOR%>13658) AND (%COLOR% Greater than Low Range
< Less than High Range
Let’s say your high range is 15467 and your low range 13678 what you have to do is add 20 or so to the high range and subtract 20 or so from the low range.
The code would look like this:
GetPixelColor>X,Y,COLOR
IF>{(%COLOR%>13658) AND (%COLOR% Greater than Low Range
< Less than High Range
Thanks for the hint, thougt about that as well - but:
The range can be very high, so i can tell nothing about a hit for a pixel. This happens every time, the first value (red) changes a bit or the numer of digits for one of the folling blue/green) changes.
And that's exactly my problem to pinpoint the right color range.
Try to get the RGB-values from this color:
color: 1213132
012 - 131 - 032 ?
121 - 031 - 032 ?
012 - 013 - 132 ?
You see, splitting the colors in RGB is quite difficult - for this example, i can't tell if it's mainly blue, green or red. But this can happen in my case.
IF I could split the value from GetPixelColot in it's RGB-Values, i could check every color channel for a small change. But the calculating from the given value is tricky - it's not a exact computable array of variables with the given information (leading zeroes would be fine
)
The range can be very high, so i can tell nothing about a hit for a pixel. This happens every time, the first value (red) changes a bit or the numer of digits for one of the folling blue/green) changes.
And that's exactly my problem to pinpoint the right color range.
Try to get the RGB-values from this color:
color: 1213132
012 - 131 - 032 ?
121 - 031 - 032 ?
012 - 013 - 132 ?
You see, splitting the colors in RGB is quite difficult - for this example, i can't tell if it's mainly blue, green or red. But this can happen in my case.
IF I could split the value from GetPixelColot in it's RGB-Values, i could check every color channel for a small change. But the calculating from the given value is tricky - it's not a exact computable array of variables with the given information (leading zeroes would be fine

-
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
This not very elegant code converts a macroscheduler color number (px) to RGB. (I'm sure Marcus will now post a single line solution
)
GetPixelColor>%xpos%,%ypos%,px
Let>px2={%px% MOD 16}
Let>px3={(%px%-%px2%)/16}
Let>px4={%px3% MOD 16}
Let>red={%px2%+(%px4%*16)}
Let>px5={(%px3%-%px4%)/16}
Let>px6={%px5% MOD 16}
Let>px7={(%px5%-%px6%)/16}
Let>px8={%px7% MOD 16}
Let>green={%px6%+(%px8%*16)}
Let>px9={(%px7%-%px8%)/16}
Let>px10={%px9% MOD 16}
Let>px11={(%px9%-%px10%)/16}
Let>px12={%px11% MOD 16}
Let>blue={%px10%+(%px12%*16)}
mdl>%red%-%green%-%blue%

GetPixelColor>%xpos%,%ypos%,px
Let>px2={%px% MOD 16}
Let>px3={(%px%-%px2%)/16}
Let>px4={%px3% MOD 16}
Let>red={%px2%+(%px4%*16)}
Let>px5={(%px3%-%px4%)/16}
Let>px6={%px5% MOD 16}
Let>px7={(%px5%-%px6%)/16}
Let>px8={%px7% MOD 16}
Let>green={%px6%+(%px8%*16)}
Let>px9={(%px7%-%px8%)/16}
Let>px10={%px9% MOD 16}
Let>px11={(%px9%-%px10%)/16}
Let>px12={%px11% MOD 16}
Let>blue={%px10%+(%px12%*16)}
mdl>%red%-%green%-%blue%
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Just remember that Macro Scheduler returns the values in BGR sequence (not RGB).
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?