Jump to content

Pixel Counter


Go to solution Solved by Nine,

Recommended Posts

There are many examples around it really depends on your need and goal

  • Bitblt and gdi
  • Bitblt and c# embedded if you need more speed
  • Fasm for speed
  • Dll written in other language
  • Histogram functions
  • Search with shade variations
  • ....

 

 

Link to post
Share on other sites

But you can implement the shade yourself.  It is going to slow down the scan though.

#include "GetScreen.au3"
#include <Color.au3>

HotKeySet("{ESC}", _Exit)

Local $hWnd = WinActivate("[CLASS:SciTEWindow]")
If Not $hWnd Then Exit MsgBox($MB_SYSTEMMODAL, "Error", "Unable to find window")
_GetScreen_Initialize(@DesktopWidth, @DesktopHeight)

While True
  ToolTip(_PixelCountInArea(100, 100, 500, 500, 0xFF0000, 10), 600, 500)
  Sleep(10000)
WEnd

Func _PixelCountInArea($left, $top, $right, $bottom, $color, $shade = 0)
  Local $founded = 0, $rgb1, $rgb2
  _GetScreen_GetScreen()
  $rgb1 = _ColorGetRGB($color)

  For $x = $left To $right
    For $y = $top To $bottom
      $rgb2 = _ColorGetRGB(_GetScreen_GetPixel($x, $y))
      For $i = 0 to 2
        If Abs($rgb1[$i] - $rgb2[$i]) > $shade Then ContinueLoop 2
      Next
      $founded += 1
    Next
  Next
  Return $founded
EndFunc   ;==>_PixelCountInArea

Func _Exit()
  Exit
EndFunc   ;==>_Exit

 

Link to post
Share on other sites

Your question started with pixelcounting but looking at you skyarea picture you are in need of more imagelogic

Maybe you can find some logic in

  • picture effects

 

  • getImage from findbmp

 

 

or

and search in the forum for  _GDIPlus_BitmapLockBits  or in general look at all _GDI functions for colormatrix, histogram, .....

When you have the bits (as a binarystringsequence of bytes) you can quickly search them in many algorithms where going pixel by pixel can be slow so first step is to bring down the area of interest. So first search in an 8-bit color picture.

edit: you can get some ideas with C# for speeding things up, there are examples how to integrate C# with AutoIt

Edited by junkew
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...