sebgg Posted October 17, 2011 Share Posted October 17, 2011 Hi, So have done the usual search, and kind of found what im looking for, but still comming unstuck. so example is i need to find the 4 corners of a diamond to get the smallest square it will fit into. this is however proving difficult. it seems pixelsearch always searched rows not columns, as its easy to find the top and bottom, but no way i chance the x/y variables can i get it to find the sides of the diamond. Any idea on this would be good. Cheers, Seb GC - Program to rapidly manipulate DNA SequencesRotaMol - Program to measure Protein Size Link to comment Share on other sites More sharing options...
JohnOne Posted October 17, 2011 Share Posted October 17, 2011 Can you not think of any logic whatsoever regarding how to do this? There is no single native function that is going to do it. 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 More sharing options...
sebgg Posted October 17, 2011 Author Share Posted October 17, 2011 There is no single native function that is going to do it. thats what i was affraid of, I could manage it with multiple pixelsearches, but if im doing this in the hope of optimising code that may just make it slower! Ill have a think, hopefully someone has something on this. Thanks for fast reply Seb GC - Program to rapidly manipulate DNA SequencesRotaMol - Program to measure Protein Size Link to comment Share on other sites More sharing options...
JohnOne Posted October 17, 2011 Share Posted October 17, 2011 There is a third party dll someone has made which can be found in the example forum under "advanced pixel search" that might help you, unfortunately I have never had a need for it, so I cant tell you if it has the functionality you need. 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 More sharing options...
sebgg Posted October 17, 2011 Author Share Posted October 17, 2011 There is a third party dll someone has made which can be found in the example forum under "advanced pixel search" that might help you, unfortunately I have never had a need for it, so I cant tell you if it has the functionality you need. Yeah i tried using it in the past for something as it said it was faster and it just wasnt, so not too much faith in it and would rather keep the includes down to a minimum. just finiding the top and bottom has given me about 12% inc speed, which is ok. so will stick with that for the mean time. cheers, Seb GC - Program to rapidly manipulate DNA SequencesRotaMol - Program to measure Protein Size Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 17, 2011 Moderators Share Posted October 17, 2011 sebgg, This works for me: expandcollapse popup#include <GUIConstantsEx.au3> ; Use client area coords Opt("PixelCoordMode", 2) ; Array to hold coords Global $aCoords[4] = [1000, 1000, 0, 0] ; Create GUI $hGUI = GUICreate("Test", 500, 500) $hPic = GUICtrlCreatePic("Diamond.bmp", 0, 0, 100, 100) ; Adjust to match image size GUISetState() WinWaitActive($hGUI) ; This is the diamond colour $iFore_Colour = 0x000000 ; Now run through the image For $iRow = 0 To 99 ; Adjust to match image size ; Flag to show we are over the diamond $fFore = False For $iCol = 0 To 99 ; Get pixel colour $iColour = PixelGetColor($iCol, $iRow, $hGUI) ; Adjust to match image size ; We are over the diamond If $iColour = $iFore_Colour Then ; Adjust Top coord if required If $iRow < $aCoords[1] Then $aCoords[1] = $iRow EndIf ; Adjust Bottom coord if required If $iRow > $aCoords[3] Then $aCoords[3] = $iRow EndIf ; Adjust Left coord if required If $iCol < $aCoords[0] Then $aCoords[0] = $iCol EndIf ; And set flag $fFore = True EndIf ; If we are over the diamond, look for leaving If $fFore And $iColour <> $iFore_Colour Then ; Adjust Right coord if required If $iCol - 1 >= $aCoords[2] Then ; Need -1 because we are already over the edge $aCoords[2] = $iCol - 1 EndIf ExitLoop EndIf Next Next ; Display results ConsoleWrite("L: " & $aCoords[0] & " - " & "T: " & $aCoords[1] & " - " & "R: " & $aCoords[2] & " - " & "B: " & $aCoords[3] & @CRLF) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd I used a simple black diamond on a white background. Any use? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
sebgg Posted October 17, 2011 Author Share Posted October 17, 2011 sebgg, This works for me: expandcollapse popup#include <GUIConstantsEx.au3> ; Use client area coords Opt("PixelCoordMode", 2) ; Array to hold coords Global $aCoords[4] = [1000, 1000, 0, 0] ; Create GUI $hGUI = GUICreate("Test", 500, 500) $hPic = GUICtrlCreatePic("Diamond.bmp", 0, 0, 100, 100) ; Adjust to match image size GUISetState() WinWaitActive($hGUI) ; This is the diamond colour $iFore_Colour = 0x000000 ; Now run through the image For $iRow = 0 To 99 ; Adjust to match image size ; Flag to show we are over the diamond $fFore = False For $iCol = 0 To 99 ; Get pixel colour $iColour = PixelGetColor($iCol, $iRow, $hGUI) ; Adjust to match image size ; We are over the diamond If $iColour = $iFore_Colour Then ; Adjust Top coord if required If $iRow < $aCoords[1] Then $aCoords[1] = $iRow EndIf ; Adjust Bottom coord if required If $iRow > $aCoords[3] Then $aCoords[3] = $iRow EndIf ; Adjust Left coord if required If $iCol < $aCoords[0] Then $aCoords[0] = $iCol EndIf ; And set flag $fFore = True EndIf ; If we are over the diamond, look for leaving If $fFore And $iColour <> $iFore_Colour Then ; Adjust Right coord if required If $iCol - 1 >= $aCoords[2] Then ; Need -1 because we are already over the edge $aCoords[2] = $iCol - 1 EndIf ExitLoop EndIf Next Next ; Display results ConsoleWrite("L: " & $aCoords[0] & " - " & "T: " & $aCoords[1] & " - " & "R: " & $aCoords[2] & " - " & "B: " & $aCoords[3] & @CRLF) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd I used a simple black diamond on a white background. Any use? M23 Well this is what im doing already, checking the color of every pixel in the screen to see if it meets a criteria. This is reasonably time consuming so was planning to use the pixel search function just to narrow down the search area. then carry on as normal. so unless ive missunderstood (which is quite likley) i dont think this will help. but thanks for the reply. and yeah my example was exactly that, a black diamon in paint! Great minds think alike. . . . or idiots share the same thoughts. . . u pick ^^ Cheers, Seb. GC - Program to rapidly manipulate DNA SequencesRotaMol - Program to measure Protein Size Link to comment Share on other sites More sharing options...
JohnOne Posted October 17, 2011 Share Posted October 17, 2011 If the diamond is of a constant size, a bit of logic will determine the left and right. 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 More sharing options...
sebgg Posted October 17, 2011 Author Share Posted October 17, 2011 If the diamond is of a constant size, a bit of logic will determine the left and right. very clever thought, but the diamond was just an example of the situation, it will actully be very irregular shapes, but i like the lateral thinking! Cheers, Seb GC - Program to rapidly manipulate DNA SequencesRotaMol - Program to measure Protein Size Link to comment Share on other sites More sharing options...
Bert Posted October 17, 2011 Share Posted October 17, 2011 Question: Why can't you attempt to interact directly with the control (If that is what you are attempting to do) The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
sebgg Posted October 18, 2011 Author Share Posted October 18, 2011 Question: Why can't you attempt to interact directly with the control (If that is what you are attempting to do) sorry its not a control. Sebs GC - Program to rapidly manipulate DNA SequencesRotaMol - Program to measure Protein Size Link to comment Share on other sites More sharing options...
Bert Posted October 18, 2011 Share Posted October 18, 2011 then what is it if it isn't a control? You have AutoIt installed on the virtual PC but yet you want to run it in a manner that is very odd. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
sebgg Posted October 18, 2011 Author Share Posted October 18, 2011 then what is it if it isn't a control? You have AutoIt installed on the virtual PC but yet you want to run it in a manner that is very odd. ok maybe youve said something above my head.. if when you ask, " Why can't you attempt to interact directly with the control" you mean, that the pixel searching is to find a control or something?, then no. its basically so i can measure the size of said diamond. nothing to do with controls or things like that. but if you mean directly with the pixelsearch control!?? then I have no idea how to do that sorry. could you explain? Seb GC - Program to rapidly manipulate DNA SequencesRotaMol - Program to measure Protein Size Link to comment Share on other sites More sharing options...
Bert Posted October 18, 2011 Share Posted October 18, 2011 very clever thought, but the diamond was just an example of the situation, it will actully be very irregular shapes, but i like the lateral thinking! This is what I find odd. You are being deliberately vague on "What" you are working with. You say it isn't a control. Well, I'm confused on just how to help you. Because it isn't a control how do you plan to work with these "irregular shapes" as you put it? Have a standard list of "irregular shapes" and their sizes? I want to tell you I strongly suspect you are doing something that goes against this for what you are saying can be used in such manner. I really want to be wrong on this however. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
JohnOne Posted October 18, 2011 Share Posted October 18, 2011 Regardless, of whether you understand it or not, this diamond of yours is part of some sort of control or other. Try to find out what a control is, you are getting decent advice there, try to understand it. 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 More sharing options...
sebgg Posted October 18, 2011 Author Share Posted October 18, 2011 (edited) This is what I find odd. You are being deliberately vague on "What" you are working with. You say it isn't a control. Well, I'm confused on just how to help you. Because it isn't a control how do you plan to work with these "irregular shapes" as you put it? Have a standard list of "irregular shapes" and their sizes? I want to tell you I strongly suspect you are doing something that goes against this for what you are saying can be used in such manner. I really want to be wrong on this however. I see.. it seems you have the wrong end of the stick my friend. What im doing is optimising one of the programs in my signature, RotaMol. It measures the area of protein faces (which are highly irregular) and then rotates the protein and repeats this to build up an average area of the protein. and the way i currently do it is to check every pixel on screen to see if it background color, or protein color, if its protein, i count it. and build up an area. so the idea was to try to minimise this search area (by finding the 4 corners of a diamond for example) just to minimise computation time. as it stands i dont have a list of irregular shapes, there are far too many protein conformations to be able to do it like this, and needles to say this would take a vast ammount of storage space, and is certainly outside the scope of my PhD. And @ johnOne, your right I have no idea what a control is (i thought it was just a like a dropdown menu or something), will have to do some sniffing arround. if theres a way i can do this non-graphically? that would be awesome as im guessing it will be alot faster. Do you know any good resources to start me off or is google my best friend here? Cheers, Seb. This has been up and posted in example scripts since early september, and as far as im aware is in no way against the rules of this forum. Edited October 18, 2011 by sebgg GC - Program to rapidly manipulate DNA SequencesRotaMol - Program to measure Protein Size Link to comment Share on other sites More sharing options...
JohnOne Posted October 18, 2011 Share Posted October 18, 2011 For your diamond, and any shapes really, its just a bit of logic. You get your top and bottom easily you say? so you have your middle don't you? So work your way outward from it to find your left and right. 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 More sharing options...
sebgg Posted October 18, 2011 Author Share Posted October 18, 2011 (edited) For your diamond, and any shapes really, its just a bit of logic. You get your top and bottom easily you say? so you have your middle don't you? So work your way outward from it to find your left and right. Yes but to do this i would have to check every column of pixels starting from the middle out till i hit the farthest edge (either left and right). whihc would work. but thats what im already doing in order to count each pixel. so it wont save me any time to do it twice. and really diamond is such an oversimplification , they arent even close to that regular. think more like the shape when you shoot a paintball at a wall accept no where near as symmetical, proteins are often very asymmetrical. Edited October 18, 2011 by sebgg GC - Program to rapidly manipulate DNA SequencesRotaMol - Program to measure Protein Size Link to comment Share on other sites More sharing options...
Bert Posted October 18, 2011 Share Posted October 18, 2011 I'm wrong and I stand corrected. Thank you for setting me strait. What you are asking for is very interesting. What is the color for the background? The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
JohnOne Posted October 18, 2011 Share Posted October 18, 2011 Yes but to do this i would have to check every column of pixels starting from the middle out till i hit the farthest edge (either left and right). whihc would work. but thats what im already doing in order to count each pixel. so it wont save me any time to do it twice. and really diamond is such an oversimplification , they arent even close to that regular. think more like the shape when you shoot a paintball at a wall accept no where near as symmetical, proteins are often very asymmetrical. Okay, why dont you show what you have, so people stop wasting yours and their time making suggestions you have already implimented. 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 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