Hi [USER=143394]@Counting Colors[/USER]
Well there is bad news and there is good news.
The bad news is that there is a feature in Photoshop (newer since that last time I looked) of which I was not aware.
The good news is that it is very easy now to extract a CSV file from any selection of an image for the count of pixels at any given gray level for each color channel.
All you have to do is make a select the whole image and run the measurement tool (Image > Analysis > Record Measurements
All sorts of data is recorded and at the very end of the list is "histogram"
Instead of describing the details, here is a snippet from the help file as well as a link to the help file:
Here is the link to the help file: https://helpx.adobe.com/photoshop/using/measurement.html#:~:text=Choose Image > Analysis > Ruler Tool,count items in the image.
From the measurement panel you can save the measurements to a file on your compurter and it comes in two parts, a Text file with most of the measurements and then a folder with a CSV file for each set for every measurement you have taken.
So just goes to show, not matter how long I work with PS, I am continually learning about its features.
I am sure this will provided what you need and if you need more help on how to use it just ask away
John Wheeler