Force the brightest pixels to be white, the darkest pixels to be black and spread out the ones in between quadratically such that pixels with a brightness of `n` become 50 % bright
pnmnorm -midvalue n path/to/image.pnm > path/to/output.pnm