Jump to content

How to exclude co-ordinates from PixelSearch


TeraWatt
 Share

Recommended Posts

Title says all. How would I exclude pixel co-ordinates from the PixelSearch function? I.e.: At the moment it search a rectangular/square area. I want to exclude certain co-ordinates from it so that they are not checked for certain pixel colour values.

 

Thanks in advance!

Link to comment
Share on other sites

I will be happy to help if I get the time, first give detailed description of exactly what you need.

"exclude points" is not enough, explain details of exact needs please.

Meanwhile you should at least attempt it and show your code, whether it works or not.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

But here's how it could go in au3 

you get the area you want to exclude, and from it calculate 5 areas around it that should be searched.

Like I say it's maths and math does my head in.

Here's pic to illustrate what I mean...

exclude.jpg

 

My paint skills are akin to my maths.

 

EDIT:

I reckon these might be the calculations.

;$aArea[0]left [1]top [2]right [3]bottom
Func _PixelSearchExcludeArea($iColor, $aArea)
    Local $aSearch1[4] = [0, 0, $aArea[0] - 1, $aArea[1] + 1];1
    Local $aSearch2[4] = [$aArea[3] + 1, 0, @DesktopWidth, @DesktopHeight];2
    Local $aSearch3[4] = [0, $aArea[1], $aArea[0] - 1, @DesktopHeight];3
    Local $aSearch4[4] = [0, $aArea[3] + 1, $aArea[2] + 1, @DesktopHeight];4
    Local $aSearch5[4] = [$aArea[0], 0, $aArea[2], $aArea[1] - 1];5
EndFunc   ;==>_PixelSearchExcludeArea

 

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Yes, I have read this. The problem is that this approach requires you to know, prior to program execution, the area to exclude. I want to ignore multiple points as the program runs, this means the above approach is not sufficient as there would be way too many rectangles (I.e.: I would have to re-calculate each time a new point is to be ignored).

My proposed solution, which I have yet to test, is to iterate through all points on the co-ordinate axis I wish to search (this would be the initial area) and append these values to an array. I.e.: Global $Array = [(x,y), (x2,y2), (...)]

[$Array contains all legal pixels to be checked]

I would then remove co-ordinates that should be excluded from this array.

Each point in $Array would become the parameter of the PixelSearch function, I.e.:  PixelSearch ( $Array[0][0], $Array[0][1], $Array[0][0]+1, $Array[0][1]+1, <colour code> )

As each pixel is 1x1 (hence the increment of 1). Checks would be performed in a loop, iterating through all points in $Array.

[I am new to AutoIt, the list slicing I am performing is as a result of my Python intuition, also these points may be incorrect]

Edited by TeraWatt
Link to comment
Share on other sites

13 minutes ago, JohnOne said:

But here's how it could go in au3 

you get the area you want to exclude, and from it calculate 5 areas around it that should be searched.

Like I say it's maths and math does my head in.

Here's pic to illustrate what I mean...

exclude.jpg

 

My paint skills are akin to my maths.

A more efficient approach would only require 4 rectangles. 

In my problem multiple black squares are scattered around so this would not be feasible. 

Link to comment
Share on other sites

24 minutes ago, TeraWatt said:

A more efficient approach would only require 4 rectangles. 

 

Perhaps, but problems might arise if area was top of screen, so more coding.

Your approach sounds better for your goals.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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...