Delphi and Kylix

Moderators: pritaeas
Number of threads: 7244
Number of posts: 19051

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
pixel analyser Posted by pascal-coder on 6 Feb 2006 at 8:37 AM
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 :)
Report
Re: pixel analyser Posted by IDK on 6 Feb 2006 at 8:49 AM
: 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:

foreach pixel
  if it is white increse white
  else if it is black increse black


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

Happy coding wishes
the one and only
Niklas Ulvinge aka IDK

Report
Re: pixel analyser Posted by pascal-coder on 6 Feb 2006 at 8:55 AM
: : 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:
:
:
: foreach pixel
:   if it is white increse white
:   else if it is black increse black
: 

:
: white now has the number of white pixels and black the number of black.
:
: Happy coding wishes
: the one and only
: Niklas Ulvinge aka IDK
:
:
Thanks a lot but how do I check each pixel?(with an array?)
could some on give me an example please.
Report
Re: pixel analyser Posted by zibadian on 6 Feb 2006 at 1:15 PM
: : : 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:
: :
: :
: : foreach pixel
: :   if it is white increse white
: :   else if it is black increse black
: : 

: :
: : white now has the number of white pixels and black the number of black.
: :
: : Happy coding wishes
: : the one and only
: : Niklas Ulvinge aka IDK
: :
: :
: 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:
  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;




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.