pixel analyser - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# pixel analyser

Posts: 40Member
I don't know if theres a way to solve my problem, but I still wan't to ask.
Is there a way of analysing a picture(black and white)to find out how many
pixels are very dark(black) and how many are very light?

• Posts: 1,784Member
: I don't know if theres a way to solve my problem, but I still wan't to ask.
: Is there a way of analysing a picture(black and white)to find out how many
: pixels are very dark(black) and how many are very light?
:
do a loop that increses variables like this:

[code]
foreach pixel
if it is white increse white
else if it is black increse black
[/code]

white now has the number of white pixels and black the number of black.

Happy coding wishes
the one and only
[b]Niklas Ulvinge[/b] [white]aka [b]IDK[/b][/white]

• Posts: 40Member
: : I don't know if theres a way to solve my problem, but I still wan't to ask.
: : Is there a way of analysing a picture(black and white)to find out how many
: : pixels are very dark(black) and how many are very light?
: : Thanks already
: :
: do a loop that increses variables like this:
:
: [code]
: foreach pixel
: if it is white increse white
: else if it is black increse black
: [/code]
:
: white now has the number of white pixels and black the number of black.
:
: Happy coding wishes
: the one and only
: [b]Niklas Ulvinge[/b] [white]aka [b]IDK[/b][/white]
:
:
Thanks a lot but how do I check each pixel?(with an array?)
could some on give me an example please.
• Posts: 6,349Member
: : : I don't know if theres a way to solve my problem, but I still wan't to ask.
: : : Is there a way of analysing a picture(black and white)to find out how many
: : : pixels are very dark(black) and how many are very light?
: : : Thanks already
: : :
: : do a loop that increses variables like this:
: :
: : [code]
: : foreach pixel
: : if it is white increse white
: : else if it is black increse black
: : [/code]
: :
: : white now has the number of white pixels and black the number of black.
: :
: : Happy coding wishes
: : the one and only
: : [b]Niklas Ulvinge[/b] [white]aka [b]IDK[/b][/white]
: :
: :
: Thanks a lot but how do I check each pixel?(with an array?)
: could some on give me an example please.
:
This example is based on a TBitmap:
[code]
with Bitmap do
for x := 0 to Width-1 do
for y := 0 to Height-1 do
case Canvas.Pixels[x, y] of
clWhite: Inc(NumberOfWhite);
clBlack: Inc(NumberOfBlack);
end;
[/code]