Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Need help determining what an image is

  • 30-08-2008 5:14am
    #1
    Registered Users, Registered Users 2 Posts: 695 ✭✭✭


    Title sucks so better explanation now. This is a follow on from the previous post I made but now I've encountered a different problem. I'm writing a program that parses data from another programs window. The problem is the program I'm parsing seems to be in some sort of flash format, this means that I cannot grab text or control info. So I wrote a function that gets me text (that was the other thread). However the program also has 50 images of all the same size and I need to find out what image is currently being displayed.

    Here's an example imagine a program that randomly displayed a single smilie image (ie. :pac::D;)), and I have to find which smilie it is.

    At first I thought this was easy, since I have access too the actual jpg's the program uses, and I could simply edit each pic and give them a unique pixel color in a specific area of each pic, and then all I have to do is scan that specific pixel and depending on what colour it is I know what image it is. However I found that the program actually crops the images slightly and and the result is some of the colours become lighter or darker shades (I dont know if this is a result of dithering the program does) and then I have collisions.

    So I spent a few hours re editing some images over and over to get it working, and result is a few hours later I can accurately identify the image most of the time, but that's not good enough.

    I find when I'm in this spot it's sometimes best to just take a step back and forget the current method I'm using and try think of a new one that is far more straightforward. Anyone any ideas?


Comments

  • Registered Users, Registered Users 2 Posts: 5,112 ✭✭✭Blowfish


    Assuming it doesn't matter that you are editing pixels then you could just use a slight variation on what you already have. Just use 6 pixels and have them either black or white, essentially giving you a binary number for each image. Then just use <50% R,G,B as Black and >=50% R,G,B as white. The slight variation in shading the program does isn't going to shift it from one to the other.


  • Registered Users, Registered Users 2 Posts: 695 ✭✭✭DaSilva


    There is 50 images though, which is the problem at the moment, I've just started making each image totally one colour and saving them in a lower colour depth in the hopes the program doesn't need to do it's own dithering anymore. Problem is the images appear randomly so I have to sit there running an AHK script to get the colour and then write it down. Some colours are too close too each other though and the program makes them the same so have to re edit those images, which means closing the program, opening up the image, edit, save, reload the program, and then wait for the image to reappear. It's tedious though I will do it :P just wondering if there is a nicer solution to this problem :D


  • Registered Users, Registered Users 2 Posts: 5,112 ✭✭✭Blowfish


    DaSilva wrote: »
    There is 50 images though, which is the problem at the moment, I've just started making each image totally one colour and saving them in a lower colour depth in the hopes the program doesn't need to do it's own dithering anymore. Problem is the images appear randomly so I have to sit there running an AHK script to get the colour and then write it down. Some colours are too close too each other though and the program makes them the same so have to re edit those images, which means closing the program, opening up the image, edit, save, reload the program, and then wait for the image to reappear. It's tedious though I will do it :P just wondering if there is a nicer solution to this problem :D
    Well that's what I mean, if you are going to have to edit the 50 images anyway, why not just directly manipulate 6 of the pixels into what is guaranteed to work?


  • Registered Users, Registered Users 2 Posts: 695 ✭✭✭DaSilva


    Blowfish wrote: »
    Well that's what I mean, if you are going to have to edit the 50 images anyway, why not just directly manipulate 6 of the pixels into what is guaranteed to work?

    Thats the problem, it isn't guaranteed to work, some similar shades will be made to be the same colour I've found. I think it's the only way though, problem is 50 images and it can take 1min+ for the next image to appear, so think im gonna write a script that finds the colour and if its not one i wrote down already then msgbox so i dont have to sit there watching and checking notepad if i got that one already :P


  • Registered Users, Registered Users 2 Posts: 5,112 ✭✭✭Blowfish


    DaSilva wrote: »
    Thats the problem, it isn't guaranteed to work, some similar shades will be made to be the same colour I've found. I think it's the only way though, problem is 50 images and it can take 1min+ for the next image to appear, so think im gonna write a script that finds the colour and if its not one i wrote down already then msgbox so i dont have to sit there watching and checking notepad if i got that one already :P
    Well that's what I'm saying. If you actually have access to the images that will display, you can manipulate the images directly to display 6 black/white pixels. 6 pixels, each being either black or white will give you 64 options. Image 0 will have all 6 pixels black (000000), image 1 will have the first 5 black and the last white (000001), image 2 will have 4 black, one white, one black (000010), image 3 will have 4 black 2 white (000011) etc.

    No amount of dithering will convert a black pixel into a white one :)


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 695 ✭✭✭DaSilva


    Blowfish wrote: »
    Well that's what I'm saying. If you actually have access to the images that will display, you can manipulate the images directly to display 6 black/white pixels. 6 pixels, each being either black or white will give you 64 options. Image 0 will have all 6 pixels black (000000), image 1 will have the first 5 black and the last white (000001), image 2 will have 4 black, one white, one black (000010), image 3 will have 4 black 2 white (000011) etc.

    No amount of dithering will convert a black pixel into a white one :)

    I can't use black however as the background of the program is black, and my program wont know if its looking at the background or an image if i use black. Also the program renders some greys as transparent, it also does things like makes 0x00FF13 -> 0x00FF11 and stuff like that, also worried that doing it this way will mean it's not portable as other peoples desktop colour bit depth might alter how the program renders some colours.


Advertisement