Pixel Counting…Please help!

J
Posted By
JoeSetsFire
May 3, 2004
Views
2347
Replies
7
Status
Closed
Hi I am trying to count the number of black pixels in an image and wondering how this would be done? I am actually trying to count the number of pixels selected by a magic wand selection!

I don’t mean an area of pixels, but an exact amount, for example if my picture was a white background with a black stick man on it, I would want to know the exact number of black pixels, not the number of pixels in the rectangular/square selection box around him…

It would be so great if somebody would help with this, I need to know how to do it for a project I am doing on Data Images, and it is necessary to do this to get an accurate Data-Ink ratio! Thanks alot Beforehand to anybody who answers this!

– Joe

Must-have mockup pack for every graphic designer 🔥🔥🔥

Easy-to-use drag-n-drop Photoshop scene creator with more than 2800 items.

MM
Mac_McDougald
May 3, 2004
After any selection, look at histogram. Will tell you exact number of selected pixels.

Mac
MM
Mick_Murphy
May 3, 2004
This is interesting. First, make sure you click the exclamation mark in the Histogram palette or the numbers will be way out.

I just tried this with the magic wand set to discontiguous and tolerance of 0 and did the same with the Color Range command set to 0 as well on an image with about 676,000 pixels. The count with the Magic Wand is about 60,000 whereas with Color Range it is about 47,000. I wrote a little program which can count the number of pixels of a particular colour and trying it on the same file I get a figure of about 47,000 (100 or so different from Color Range). I can’t remember offhand why there should be such a difference between Magic Wand and Color Range but I think Deke McClelland had an explanation in his Bible. I must check this out.
MM
Mac_McDougald
May 4, 2004
… make sure you click the exclamation mark in the Histogram palette

I don’t HAVE exclamation mark there (PS 7).

Mac
JH
Joe_Hastings
May 4, 2004
Neither do I 🙁 maybe is a CS thing (need more ££££££)

But I can always go into the labs at uni to do it, but that involves moving…ahhh well, guess I will have to! Thanks for the advice! Let me know if you find out the reason for the strange differences!

Cheers!
Joe
MM
Mick_Murphy
May 4, 2004
Quick to forget. In CS there is a separate histogram palette and it shows data from cache which is very different from reality until you hit the exclamation symbol which causes it to update.
JH
Joe_Hastings
May 4, 2004
ahhh okay, didn’t know that! Will have to stick with the PS7 method for now then! But thanks for the help, hopefully will get CS soon enough, so that is a good thing to remember when I get it!

Cheers!
Joe
TT
Toby_Thain
May 5, 2004
If you are trying to count the number of selected pixels:

Enter Quick Mask*
Open Histogram window

As you move your cursor over the graph, you’ll see the Percentile figure changing. When the cursor is on the leftmost (black) column of the histogram, the percentile is the % of NON selected pixels. Subtract this figure from 100% to get the percentage of selected pixels. That sounds like the ratio you’re looking for. (If you prefer to work with counts rather than percentages, look at the Count figure.)

* instead of using Quick Mask, you can Save Selection, select the new channel, and Select None before opening Histogram.

Must-have mockup pack for every graphic designer 🔥🔥🔥

Easy-to-use drag-n-drop Photoshop scene creator with more than 2800 items.

Related Discussion Topics

Nice and short text about related topics in discussion sections