counts=ConstantArray[0,256];
f[x_]:=Block[{b=Clip[Floor[255*x+.5],{0,255}]},
counts[[b+1]]++];
ImageFileScan[f,ExampleData[{"TestImage","Man"},"FilePath"]];
ListLinePlot[counts,InterpolationOrder->0,Filling->Bottom]