FindImagePOS problem with variable background

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Louise
Newbie
Posts: 4
Joined: Sat Jul 17, 2010 2:09 pm

FindImagePOS problem with variable background

Post by Louise » Sat Jul 17, 2010 2:15 pm

The situation I am trying to resolve is that I have a icon I need to find on the screen. The icon is superimposed on a variable background, and I cannot control what the background will be.

The ideal solution would be if FindImagePos supported a transparant colour that would mark those pixels as not to be tested, but I gather that this is a feature that so far resides on the wish list.

Does anyone have any suggestions as to how I might perform this operation?

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Sat Jul 17, 2010 6:24 pm

I'm sure that there is a great deal of the icon which is
not transparent (otherwise you wouldn't see it LOL)

The bitmap image you task FindImagePos to find can be just a
portion of the icon (the non transparent parts).

Use ms paint or some other bitmap image editing program where you can zoom in and enlarge the icon really big, then cut out a portion of the image which will most likely be unique and opaque.

Set the variable FIP_SCANPIXELS to the number of pixels to scan - instead of the default 100 so that it is very accurate on this small image.

Louise
Newbie
Posts: 4
Joined: Sat Jul 17, 2010 2:09 pm

Post by Louise » Sat Jul 17, 2010 6:46 pm

Yes, I've been attempting to do this, but there just simply isn't a suitable area.

The icon is a white, hollow circle with a small!! triangle on the side.

I could do just a subset of the triangle, but that would match any block of white on the screen.

The backgrounds are HIGHLY variable, altering the shade near continuously, and the primary hue altering at frequent, but irregular intervals.

I guess I could look for all matches of a pure white square that is the largest that will fit in the triangle, and then check for offset pixels being white too. That will work for most backgrounds, but will be horrible when the background has a large portion of white in it :)

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Sat Jul 17, 2010 8:12 pm

It's worth asking then, just why do you need to find this icon? Most of the time there is more than one way to accomplish a task, and I would hate to think you are pulling your hair out trying to go in one direction, when an easier approach exists.

As an example: You don't need to find an icon on the desktop in order to click on it and launch a program -- the more direct route is to just launch the shortcut or executable directly in code.

Your issue may be different, but my point is image recognition may not be your best approach. If you describe the actual root problem, it would be easier to suggest a solution.

Louise
Newbie
Posts: 4
Joined: Sat Jul 17, 2010 2:09 pm

Post by Louise » Sat Jul 17, 2010 9:04 pm

I have a large number of files, containing maps. The icon in question is a marker for a particular category of location, and exists on an overlay that is superimposed on the image. Unfortunately the image files are not multilayer, so I need to pick the markers out of the raw image.

What I am trying to achieve, is a macro to drive a viewer for these images, and count the number of markers on each.

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Post by gdyvig » Sat Jul 17, 2010 9:14 pm

Hi Louise,


Does the variable background contain any white pixels?
If not you may be able to make that part of your needlefile a shade of gray and use a color tolerance that does not include white.

The border of the circle icon is white, and how wide?

Is the largest expanse of white larger than the circle icon?

Is the variable background adjacent to the other white areas?
If not, you may be able to use a 2-pixel needlefile to find the inside edge of the circle icon.


Gale

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts