Jump to content

Gradient Search


Recommended Posts

For example i have a pixel that can change its color in a huge color range. And i need to do some action when that pixel gets any color of gradient from black to white. Is it possible to use ane PixelGetColor or PixelSearch commands? Can u show me how to use them when i need to search for color range in 1 pixel

Edited by Belfigor

[size="1"]My bear is so cute asleep in the closet, not even drinking vodka. My nuclear bomb name is Natasha.[/size]

Link to comment
Share on other sites

Create an Array with all possible Clors and the do

$isinColorrange = ArraySearch($colors,PixelGetColor(x,y))

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Create an Array with all possible Clors and the do

$isinColorrange = ArraySearch($colors,PixelGetColor(x,y))

And how to create an Array? Im very new in AutoIt :D

[size="1"]My bear is so cute asleep in the closet, not even drinking vodka. My nuclear bomb name is Natasha.[/size]

Link to comment
Share on other sites

Dim $Array[ NumberOfEntries ] = {Entry1,Entry2,...}

Or

Dim $Array[ NumberOfEntries ]

$array[0] = Entry 1

$array[1] = Entry 2

_ArraySearch is in the include Array.au3

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Dim $Array[ NumberOfEntries ] = {Entry1,Entry2,...}

Or

Dim $Array[ NumberOfEntries ]

$array[0] = Entry 1

$array[1] = Entry 2

_ArraySearch is in the include Array.au3

Big thx, will test it when will come home.

[size="1"]My bear is so cute asleep in the closet, not even drinking vodka. My nuclear bomb name is Natasha.[/size]

Link to comment
Share on other sites

Big thx, will test it when will come home.

Its impossible to set an array for all colors that are between white and black. there are thousands of colors.

Is there another way to search a pixel for a huge range of colors? May be something like:

PixelSearch (1, 1, 3, 3, (0xFFFFFF - 0x000000))

???

Edited by Belfigor

[size="1"]My bear is so cute asleep in the closet, not even drinking vodka. My nuclear bomb name is Natasha.[/size]

Link to comment
Share on other sites

Maybe this way:

$x = PixelSearch()
$x = Hex($x,6)
$r = Stringleft($x,2)
$g = StringMid($x,3,2)
$b = StringRight($x,2)
If ($r = $g) and ($g = $B) Then
 ; Colors are gray, white or black.
Endif

This way you cant have Colors like 0xAAAAAB or ox000001

They must be oxFFFFFF or 0xDDDDDD or 0x111111 ... (Allcolors the syme value)

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Maybe this way:

///

Its a good idea but it will not work :D

I need to search for any color from gradient on the picture. Is it possible?

post-34243-1208110705_thumb.jpg

[size="1"]My bear is so cute asleep in the closet, not even drinking vodka. My nuclear bomb name is Natasha.[/size]

Link to comment
Share on other sites

What do you mean search for any color?

Anything not greyscale?

If that is the case you can pixel scan that entire line from left to right for example, and when a pixelgetcolor returns a decimal that is outside the whites range, exitloop.

While 1
    For $Line = 1 To 300 ;length of the scan line in pixels
        If PixelGetColor($InitialPosition + $Line, 345) < 14777215 Then ;you've hit the color range you are after                           
            ExitLoop
            ExitLoop
        EndIf
    Next
    Sleep(10)
WEnd
Edited by LogicalAI
Link to comment
Share on other sites

I am not sure what your question means exactly but it looks like

study pixelsearch in the help

study pixelgetcolor in the help

Look at thread http://www.autoitscript.com/forum/index.ph...mp;#entry493137

1. Sample code to get all hex colors for a certain area

$startX=46
$endX=48
$startY=3
$endY=8
for $x=$startX to $EndX
   for $y=$startY to $endY
        consolewrite(hex(pixelgetcolor($x,$y)) & ";")
   next
   consolewrite(@CRLF)
next

2. Check if a certain color is in a certain range

if pixelGetColor($x,$y)>.... and pixelGetColor($x,$y)<....

3. You only can get a color of a certain location and have to check yourself for the right colors including the gradient

Search in the forum as some solution(s) are there all based on basic commands like pixelgetcolor, pixelsearch, bitblt, getDIBits, reading the bytes of the colors into an array and checking yourself.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...