# Counting Pixels

Discussion in 'NZ Computing' started by Lindsay.Rollo@paradisedotnetdotnz, Dec 4, 2009.

Is there a simple way to determine the number of black pixels in
a specimen text block?

I want to compare the differences in the number of pixels used to
display the specimen text block in different type faces.

Lindsay.Rollo@paradisedotnetdotnz, Dec 4, 2009

2. ### Lawrence D'OliveiroGuest

In message <>,

> Is there a simple way to determine the number of black pixels in
> a specimen text block?

render(the_text, pixbuf);
nrblack = 0;
for (row = rowmin; row < rowmax; ++row)
{
for (col = colmin ; col < colmax; ++co)
{
if (getpixel(pixbuf, row, col) == black)
{
++nrblack;
} /*if*/
} /*for*/
} /*for*/

Lawrence D'Oliveiro, Dec 4, 2009

I was hoping someone woul;d know a readily available program that
would give me the answer, as I'm not a programmer.

Lindsay.Rollo@paradisedotnetdotnz, Dec 4, 2009
4. ### Craig SuttonGuest

"Lawrence D'Oliveiro" <_zealand> wrote in message
news:hfack1\$5oq\$...
> In message <>,
>
>> Is there a simple way to determine the number of black pixels in
>> a specimen text block?

>
> render(the_text, pixbuf);
> nrblack = 0;
> for (row = rowmin; row < rowmax; ++row)
> {
> for (col = colmin ; col < colmax; ++co)
> {
> if (getpixel(pixbuf, row, col) == black)
> {
> ++nrblack;
> } /*if*/
> } /*for*/
> } /*for*/
>

NERD for knowing that

Craig Sutton, Dec 4, 2009
5. ### Lawrence D'OliveiroGuest

In message <hfapif\$dq5\$>, Craig Sutton wrote:

> "Lawrence D'Oliveiro" <_zealand> wrote in message
> news:hfack1\$5oq\$...
>
>> In message <>,
>>
>>> Is there a simple way to determine the number of black pixels in
>>> a specimen text block?

>>
>> render(the_text, pixbuf);
>> nrblack = 0;
>> for (row = rowmin; row < rowmax; ++row)
>> {
>> for (col = colmin ; col < colmax; ++co)
>> {
>> if (getpixel(pixbuf, row, col) == black)
>> {
>> ++nrblack;
>> } /*if*/
>> } /*for*/
>> } /*for*/
>>

>
> NERD for knowing that

Thatâ€™s right, I forgot this is actually nz.knitting. My abject apologies for
posting something related to how you actually use computers.

Lawrence D'Oliveiro, Dec 4, 2009
6. ### Lawrence D'OliveiroGuest

In message <>,

> I was hoping someone woul;d know a readily available program that
> would give me the answer, as I'm not a programmer.

Hire a programmer, then.

Lawrence D'Oliveiro, Dec 4, 2009
7. ### MeGuest

Lawrence D'Oliveiro wrote:
> In message <>,
>
>> I was hoping someone woul;d know a readily available program that
>> would give me the answer, as I'm not a programmer.

>
> Hire a programmer, then.
>

If the OP wants a windows executable to do the job, post again here and
It will take little time to do, yet be more productive than Larry D'O's
entire career on usenet.

Me, Dec 6, 2009

Me <>::

>If the OP wants a windows executable to do the job, post again here and

Thank you for your offer, which I accept.

You could attach the executable to an email to

I'm primarily interested in counting black pixels, but can you
will make provision for counting any color?

Cheers

Lindsay.Rollo@paradisedotnetdotnz, Dec 6, 2009
9. ### MeGuest

> Me <>::
>
>> If the OP wants a windows executable to do the job, post again here and

>
> Thank you for your offer, which I accept.
>
> You could attach the executable to an email to
>
>
>
> I'm primarily interested in counting black pixels, but can you
> will make provision for counting any color?
>

Just emailed it to you, exe file in a zip, about 215kb.
Very basic rough & ready, but works okay. To use, open a bitmap file by
clicking "Open bmp file..." button.
(not sure how you wanted to do it, but loading image as bitmap was
simplest, so you might need to save your image as a bitmap first)
Default colour of pixels to count is black, result displayed when file
Click anywhere on displayed bitmap image to select a different colour to
"count pixels", and show result.

Me, Dec 6, 2009
10. ### MeGuest

Me wrote:
>> Me <>::
>>
>>> If the OP wants a windows executable to do the job, post again here
>>> and I'll make one for free and upload it.

>>
>> Thank you for your offer, which I accept.
>>
>> You could attach the executable to an email to
>>
>>
>>
>> I'm primarily interested in counting black pixels, but can you
>> will make provision for counting any color?
>>

> Just emailed it to you, exe file in a zip, about 215kb.
> Very basic rough & ready, but works okay. To use, open a bitmap file by
> clicking "Open bmp file..." button.
> (not sure how you wanted to do it, but loading image as bitmap was
> simplest, so you might need to save your image as a bitmap first)
> Default colour of pixels to count is black, result displayed when file
> Click anywhere on displayed bitmap image to select a different colour to
> "count pixels", and show result.

Your email bounced the attached zip file. Have uploaded to server and
Cheers.

Me, Dec 7, 2009
11. ### Lawrence D'OliveiroGuest

In message <>,

> Thank you for your offer, which I accept.
>
> You could attach the executable to an email to

Ah, the old accept-executables-from-dubious-sources-on-the-Internet trick.
Works every time.

Lawrence D'Oliveiro, Dec 7, 2009
12. ### MeGuest

Lawrence D'Oliveiro wrote:
> In message <>,
>
>> Thank you for your offer, which I accept.
>>
>> You could attach the executable to an email to

>
> Ah, the old accept-executables-from-dubious-sources-on-the-Internet trick.
> Works every time.
>

I've supplied my real email address to him, as well as the URL to my
site that I've uploaded the file to, so do you still really think that
I'd send malware/trojan/virus infected code?

The only malicious thing in this thread so far has been your presence.
And no, I didn't use your code. If the OP wants my code to compile it
himself, he's welcome. You're not.

Me, Dec 7, 2009

Attention Me.

Your program achieved exactly the result I needed.

Using a word processor a test text was displayed in an otherwise
blank page, re-formatted in each type face, then a ‘Print Screen' dump
pasted into an image editor. Each pasted image was then cropped and
saved.

Black pixels were counted with PixelCounter.exe.

By adopting one value as the benchmark, and dividing all the
pixel values by the benchmark value, the process provides a direct
comparison of the relative density of black text in the test fonts.

This information is one element of making rational choices about
which type faces are more likely to be most legible in web pages.

Me, could you now sent a message to as to you
intentions about copywrite, permission to share the executable with
third parties, etc. It would be helpful also if I could give credit to
a real person rather than a non-de-plume.

Tks again for facilitating this simple piece of research.

Lindsay.Rollo@paradisedotnetdotnz, Dec 7, 2009
14. ### MeGuest

> Attention Me.
>
> Your program achieved exactly the result I needed.
>
> Using a word processor a test text was displayed in an otherwise
> blank page, re-formatted in each type face, then a ‘Print Screen' dump
> pasted into an image editor. Each pasted image was then cropped and
> saved.
>
> Black pixels were counted with PixelCounter.exe.
>
> By adopting one value as the benchmark, and dividing all the
> pixel values by the benchmark value, the process provides a direct
> comparison of the relative density of black text in the test fonts.
>
> This information is one element of making rational choices about
> which type faces are more likely to be most legible in web pages.
>
> Me, could you now sent a message to as to you
> intentions about copywrite, permission to share the executable with
> third parties, etc. It would be helpful also if I could give credit to
> a real person rather than a non-de-plume.
>
> Tks again for facilitating this simple piece of research.

As I said I'd do it for free, it's free, so I don't need credit, use and
distribute freely "as-is" without restriction.
It took a few minutes only to write and compile using a shareware
version of Delphi - a good old program for that sort of thing.

Me, Dec 7, 2009
15. ### Lawrence D'OliveiroGuest

In message <hfi4ic\$b8\$>, Me wrote:

> Lawrence D'Oliveiro wrote:
>
>> In message <>,
>>
>>> Thank you for your offer, which I accept.
>>>
>>> You could attach the executable to an email to

>>
>> Ah, the old accept-executables-from-dubious-sources-on-the-Internet
>> trick. Works every time.

>
> The only malicious thing in this thread so far has been your presence.

Interesting that I didnâ€™t use the word â€œmaliciousâ€, yet you immediately
jumped to that conclusion. Says something about your thought processes,
doesnâ€™t it?

Lawrence D'Oliveiro, Dec 7, 2009
16. ### JohnOGuest

On Dec 7, 10:44 pm, Lawrence D'Oliveiro <l...@geek-
central.gen.new_zealand> wrote:
> In message <hfi4ic\$>, Me wrote:
>
> > Lawrence D'Oliveiro wrote:

>
> >> In message <>,
> >> Lindsay.Rollo@paradisedotnetdotnz wrote:

>
> >>> Thank you for your offer, which I accept.

>
> >>> You could attach the executable to an email to

>
> >> Ah, the old accept-executables-from-dubious-sources-on-the-Internet
> >> trick. Works every time.

>
> > The only malicious thing in this thread so far has been your presence.

>
> Interesting that I didn’t use the word “malicious”, yet you immediately
> jumped to that conclusion. Says something about your thought processes,
> doesn’t it?

Yes, it shows his thought processes - both in reading your
insinuation, and in his appraisal of your general worth in this forum,
were bang on.

What else would 'works every time' mean, Larry? Don't answer, it's a
hypothetical question.

You really are a waste of space, Larry.

JohnO, Dec 7, 2009
17. ### Lawrence D'OliveiroGuest

In message <81e661f2-61e8-4679-
>, JohnO wrote:

> You really are a waste of space, Larry.

When have you actually contributed anything of value to nz.comp? It seems to
me the sum total of your postings is sniping at the comments of others. Do
you actually have any computer knowledge at all?

Lawrence D'Oliveiro, Dec 7, 2009
18. ### JohnOGuest

On Dec 8, 12:13 pm, Lawrence D'Oliveiro <l...@geek-
central.gen.new_zealand> wrote:
> In message <81e661f2-61e8-4679-
>
> >, JohnO wrote:
> > You really are a waste of space, Larry.

>
> When have you actually contributed anything of value to nz.comp? It seems to
> me the sum total of your postings is sniping at the comments of others. Do
> you actually have any computer knowledge at all?

You seem to confuse not posting steaming mountains of crap with a lack
of computer knowledge.

You need to get out more, Larry.

JohnO, Dec 8, 2009
19. ### Sailor SamGuest

JohnO wrote:
> On Dec 8, 12:13 pm, Lawrence D'Oliveiro <l...@geek-
> central.gen.new_zealand> wrote:
>> In message <81e661f2-61e8-4679-
>>
>> >, JohnO wrote:
>>> You really are a waste of space, Larry.

>> When have you actually contributed anything of value to nz.comp? It seems to
>> me the sum total of your postings is sniping at the comments of others. Do
>> you actually have any computer knowledge at all?

>
> You seem to confuse not posting steaming mountains of crap with a lack
> of computer knowledge.
>
> You need to get out more, Larry.

I'm curious as well, I would have to say my observations correlate with
what Lawrence has said.

Also, in nz.general, you claimed that a lack of postings on a point
proved that point.

/me shrugs, which was is it?

Sailor Sam, Dec 8, 2009
20. ### Sailor SamGuest

Sailor Sam wrote:
> JohnO wrote:
>> On Dec 8, 12:13 pm, Lawrence D'Oliveiro <l...@geek-
>> central.gen.new_zealand> wrote:
>>> In message <81e661f2-61e8-4679-
>>>
>>> >, JohnO wrote:
>>>> You really are a waste of space, Larry.
>>> When have you actually contributed anything of value to nz.comp? It
>>> seems to
>>> me the sum total of your postings is sniping at the comments of
>>> others. Do
>>> you actually have any computer knowledge at all?

>>
>> You seem to confuse not posting steaming mountains of crap with a lack
>> of computer knowledge.
>>
>> You need to get out more, Larry.

>
> I'm curious as well, I would have to say my observations correlate with
> what Lawrence has said.
>
> Also, in nz.general, you claimed that a lack of postings on a point
> proved that point.
>
> /me shrugs, which was is it?

er, way.

Sailor Sam, Dec 8, 2009