This implementation works on the idea that you have an ARGB pixel, if you have an RGB pixel replace:

0xFFFFFFFF with 0xFFFFFF

What I am doing is this:  

pixel = A R G B
A = 2 bytes
R = 2 bytes
G = 2 bytes
B = 2 bytes


so in hex that is:

pixel = 0xFF000000; # black
pixel = 0xFFFFFFFF; # white


A has to be FF (255) to have no transparency.

I should mention that I make an assumption with this code, that is, a pixel is in the form of a 32bit Integer.  



def markYellow(pic):
    for pix in getPixels(pic):
        if getRed(pix) &gt; 200 and getBlue(pix) &lt; 90 and getGreen(pix) &gt; 150:
            pix = 0xFFFFFFFF;
        else:
            pix = 0xFF000000;

def pctMarked(pic):
    totalPixels = 0
    whitePixels = 0
    for pix in getPixels(pic):
        if pix == 0xFFFFFFFF:
            whitePixels += 1
        totalPixels += 1
    return whitePixels / float(totalPixels)




couple of comments:
your pcMarked was only looking at red to find white, this meant it will pick up ALL fully red colours.
your markyellow function is making the pixel white instead of yellow.

Python Condensing Code
I'm looking for a (cheap, surface mount) single-chip dc/dc converter to power a USB connection. I'm thinking that with so many USB chargers available, there might be a chip available specifically targeted at just that market. So far I haven't found any, because I'm swamped with retail devices and battery charge controller chips which run FROM USB. I want to run USB from a battery. For the purposes of this question, the battery will be a 3.7v LiPo.

Does anyone know such a chip? I know I can get 5V dc/dc power converters, I'm looking to see if I can do better by finding one specifically targeted at usb host application.

While USB loads can vary, it should at least handle the typical standard USB-host load current of 500mA.
