Anyone know an algorithm to find pixel density (black to white) in an image?

Purpose: To plot the point spread function of an image taken with a microscope, so a cell, quantum dot etc..