Jump to content

Tracing the outline of an image

Recommended Posts


I've been reading these forums a lot, and decided to make my first post today! I've come across a problem statement that I cannot find on these forums.

Situation :

I will have a page which has some text and may have images. If there are images, I need to draw an outline around the image (does not have to be pixel perfect, just needs to cover the image. However, the text will be wrapped around the image with a gap of around 20-40 pixels, so I need the outline to be within that range.

I am not sure how implementable this is, considering the tool has no prior idea of what image it will be, what shape, size, etc.

(The software I am using has a feature which allows us to plot points around these images with left mouse button, and it connects each point together, so you can effectly "draw" a polygon outline. Hence, this code will have to simply plot left mouse button clicks around the image).

Can someone experienced please help me understand if this is even possible? If so, how?

Thank you in Advance!


Link to post
Share on other sites
  • Moderators


Welcome to the AutoIt forum. :)

The problem is that you do not seem to have a problem for us to solve! You say that you have software to draw the polygon around the image - so what exactly do you want AutoIt to do? Draw the polygon for you? :huh:

Please explain exactly what it is you require from AutoIt - then we can give you help and advice on how you might do it. ;)


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Link to post
Share on other sites

You can roll your own Pixel function algorithm to search the screen for pixel color contrast within a pixel distance tolerance and outline... but the devil is in the details. It would be easier, if it is a web page, to use IE functions to locate the images and start with pixel color functions starting at the center of the image working outward until you find the base color or any color that has a large contrast. Here is where YOU experiment and post your attempt.


f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

Link to post
Share on other sites


Thank you for the replies!

@Melba - Sorry I should have made it clearer. I have a software which has pictures in it (Similar to a simple word document/PDF file). I have a function in the software which allows me to plot points around these images, and then hit Ctrl + P to draw a polygon shape that connects all those points.

My question is if it is possible for Autoit to detect these images and automatically plot the points!

@Larry - Thanks a lot for that tip. This was something that I vaguely thought of (though not as well as you put it out), the problem being that the images do not have any fixed color/shape/size. Being a software engineer, I can understand that this is virtually impossible, however I just wanted to put it out there in the off chance that someone might know of some insane way to get this done!

Additional Update : It is not necessary for the script to actually DETECT the image, it is more than sufficient if it can simply plot points around an image (If I click on it, for example, or mouse over and press a hotkey). This becomes easy if all images are of the same shape/size, but obviously, its not that simple :)

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