I would like to erase by hand with a brush or eraser tool, but I only want darker colors to be erased. For example, if a pixel under the brush is 100% black (luminosity=0), it would get 100% erased (turned to opacity/alpha=0%). If a pixel is a dark blue (say luminosity=20), it would get 80% erased (alpha=20%). If a pixel is solid white, it would be untouched (alpha=100%).
This question is about photoshop, but an answer that works in a different but free graphics program will be just as good or better. Thank you.