Pixel Color Conversion to 256 color RGB

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Waldo
Junior Coder
Posts: 20
Joined: Fri Oct 29, 2004 4:22 am

Pixel Color Conversion to 256 color RGB

Post by Waldo » Sun Jun 06, 2010 1:55 pm

Does anyone have a subroutine to convert a pixel color to a one of 256 colors?

My current product uses image recognition by examining pixel colors at certain locations. WHITE has always been WHITE up through 32-bit displays. But now my new windows 7 64-bit computer returns multiple values over a screen area that used to be simply WHITE.

UPDATE: !!!
My mistake.... I found out that the GetPixelColor x,y coordinates were not showing the true color AT the mouse pointer. That's not an error on Macro Schedulers part... It was a bug in my hi-res monitor software. Everything worked fine after I re-selected the monitor resolution. It had been positioning the mouse WELL AHEAD of the actual pixel... resulting in an incorrect color being reported.

Along the way, I found a useful FREE utility called PIXIE.EXE by Nattyware that reports pixel color at the mouse pointer in terms of BINARY and hex values.... very useful. It confirmed that the x,y,colors returned by Macro Scheduler were correct.
Last edited by Waldo on Mon Jun 07, 2010 1:20 am, edited 2 times in total.

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Sun Jun 06, 2010 2:04 pm

You don't say which image recognition command specifically you are having problems with, but some of them have a color_tolerance parameter. Have you tried this?

If color_tolerance is zero the pixel colors must match exactly. color_tolerance can be set to a value between 0 and 255. If larger than zero the red, green and blue values of the pixels in bitmap_to_scan are checked to see if they are within the tolerance specified (color value + or - color_tolerance). Smaller values match less and larger values match more.

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Post by gdyvig » Sun Jun 06, 2010 2:37 pm

This thread contains code to convert color code to pixel color:
http://www.mjtnet.com/usergroup/viewtop ... hlight=rgb

The new LCD monitors have the best looking display when font smoothing is turned on. Unfortunately this introduces numerous additional colors in the white background near text and other graphics. Turn off all display effects to simplify the display. I believe this is the most likely cause of your problem. I don't know of any way to remove the artifacts.

However you say something else may be going on with the 64 bit version of Windows 7 - the color intensity range is no longer 0-255(8 bits per channel), but 0-65535(16 bits per channel)? That is unlikely unless your clients are using high-end monitors needed for applications like medical imaging. Macro Scheduler should be capturing 24 or 32bit images (8 bits per channel) and doing the conversion for you.



Gale

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts