qwertylol Posted May 15, 2007 Share Posted May 15, 2007 (edited) I am doing search for a horizontal line, I want to check every color on a (x,y) = (0, 327) ~ (1023, 327 ) and I want to calculate the center of the individual strings. see the pic attached, it essentially comes down to how to judge on the length of a string, say, if there is another point of the same color within, like 4 pixels to the right (or left), then the length of the string is increased by that much. but I am not sure how to store the position of the string and how long it is. Edited May 15, 2007 by qwertylol Link to comment Share on other sites More sharing options...
Davo Posted May 16, 2007 Share Posted May 16, 2007 (edited) Hi, I don't know if this is what your after, I just wrote it up quickly hoping it can help you or maybe you can get something out of it. Basically it scans the line looking for black, when it finds it, it increases the scan area to a small rectangle and makes sure black exists within that rectangle. When it suddenly doesn't exist the error is set, the loop exited and the midpoint is calculated. I think you will get the picture. Hope it helps. Dave CODE Func _getStringMidpoint() ;declare and initialise the variables Local $x = 0 Local $y = 327 Local $i = 0 Local $pixelColor Local $midPoint ;enter the for loop that scans the pixels For $x = 0 To 1023 Step 1 $pixelColor = PixelGetColor($x,$y) If $pixelColor == 0 Then $i = $x SetError(0) Do PixelSearch($i,$y+4,$i+4,$y-4,0) $i += 1 Until @error == 1 $midPoint = ($i - $x) / 2 ; ;enter what you want to do with this answer here, eg write it to file,make it a message in a messagebox ; ;set the value of $x to $i so we don't rescan areas already done $x = $i EndIf Next EndFunc Edit: Made it more accurate and fixed a potential issue Note: THIS CODE IS NOT TESTED! Dave Edited May 16, 2007 by Davo ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------"I don't need to know everything, I just need to know where to find it when I need it"....EinsteinAnd in our case... That's the AutoIT helpfile ;) Please read before posting!!! Link to comment Share on other sites More sharing options...
Davo Posted May 16, 2007 Share Posted May 16, 2007 Did a bit more testing, came up with these improvments, still not 100% accurate but its close CODE _getStringMidpoint() Func _getStringMidpoint() ;declare and initialise the variables Local $x = 0 Local $y = 327 Local $i = 0 Local $pixelColor Local $midPoint = 0 ;enter the for loop that scans the pixels For $x = 0 To 1023 Step 1 $pixelColor = PixelGetColor($x,$y) If $pixelColor == 0 Then $i = $x SetError(0) Do PixelSearch($i,$y+5,$i+10,$y-5,0) $i += 1 Until @error == 1 $midPoint += $x + (($i - $x) / 2) $midPoint = Round($midPoint) ; ;msgbox(0,"",$midPoint) ; ;set the value of $x to $i so we don't rescan areas already done $x = $i EndIf Next EndFunc Dave ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------"I don't need to know everything, I just need to know where to find it when I need it"....EinsteinAnd in our case... That's the AutoIT helpfile ;) Please read before posting!!! Link to comment Share on other sites More sharing options...
qwertylol Posted May 18, 2007 Author Share Posted May 18, 2007 what I am trying to find only how to find out the location of the string, and the length. is it possible to do, without knowing what the string is ? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now