Sign in to follow this  
Followers 0
ratacat

is there a 'pixel count' sort of function?

3 posts in this topic

Here is what I want to do...and I was hoping for suggestions or at least some places to start on how I might get there.

Lets say I have a small area about 50 x 50 pixels that I want the script to 'watch'. It is constantly moving, and changing colors but, I was hoping I could make a way for it to count the aprox number of pixels that fit under general 'red' 'blue' 'green' 'white' catogory. I need to be able to tell when a large (x10 or x15 normal amount) of white(and various subshades) of pixels flood the 50 x 50 pixel screen segment.

I can't think of any way to start this...any help or direction would be great. The pixelsearch macro doesn't quite cut it...and the getpixelcolor doesn't really work without some serious loopage + farout highmathetics.

actually...maybe the getpixelcolor WOULD be the place to start.

Could loop it to search through that 50 x50 segment...say point xy with 50 pixels in all directions. and save data as it goes...the only real question/problem with that would be that I don't have a good accurate view of how to quanify the different shades of white as compared to blue/red etc etc..

Thanks in advance for ANY advice or recomendations.... =)

Share this post


Link to post
Share on other sites



You just use a couple For loops to scan an area for pixels.

I think I actually made one:

Func _GetAllPixels($StartX, $StartY, $EndX, $EndY, $Color)
   Local $aCoord, $Length, $Width, $Area,_
         $i, $x, $y, $CurrentElement = 1
  
  ; Get area of rectangle to initiate array
   $Length = Abs($StartX - $EndX)
   $Width = Abs($StartY - $EndY)
   $Area = $Length * $Width
   Dim $aReturn[$Area + 1][2]

  ; Search inside rectangle for the pixel
   For $x = $StartX to $EndX
      For $y = $StartY to $EndY
         If PixelGetColor( $x, $y) = $Color Then
            $aReturn[$CurrentElement][0] = $x
            $aReturn[$CurrentElement][1] = $y 
            $CurrentElement = $CurrentElement + 1
         EndIf
      Next
   Next

   ReDim $aReturn[$CurrentElement][2]
   $aReturn[0][0] = $CurrentElement - 1
   
   Return $aReturn
EndFunc

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites

Offering any help to anyone (to my capabilities of course)Want to say thanks? Click here! [quote name='Albert Einstein']Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.[/quote][quote name='Wolvereness' date='7:35PM Central, Jan 11, 2005']I'm NEVER wrong, I call it something else[/quote]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0