• Status: Solved
• Priority: Medium
• Security: Public
• Views: 635

# Loading differnt images into a timage, and clicking on differnt parts of the image.

Hi all i have a timage i will be adding differnt  images into the timage. Look at image links below.
http://www.grantfullen.com/ACondence.bmp
http://www.grantfullen.com/Front Bumper.bmp
Look at each image each has numberd parts. I need a way i can click on each number 1,2,3 and so on. If i click on a 1 then a will for example ShowMEssage('1clicked'), or if clck on 2 then, Showmessage('2clicked').
This is no problem to do if i was just useing the same image, but sine I will have differnt images with differnt numbers I need a dynamic solution .
Thanks  for looking / helping
Grant
0
Grant Fullen
• 4
• 4
• 3
1 Solution

Commented:
well ... from the looks of it, there is no general way to do it. In theory you could just use OCR and detect the numbers, then using some algorithm (any kind really) search around the number for the connecting line and then using yet anotehr algorithm to detect the surroundings of the object. problem is for example in http://www.grantfullen.com/ACondence.bmp where no algorithm on this planet can dinamically distinguish between 4, 6 and 7.
just put it simply: impossible to do dinamically.

BUT, you can use a map kind of data for each image, that stores the coordinates of the objects and it's numbering. or better yet, using a mask (but this will eat up some space, but nowadays that is not a problem, especially if using jpgs).

I would recommend using the second aproach with a mask.
0

Author Commented:
Well i am looking for a solution. Show me some code with the mask that will work and you can have the points.
Thanks
Grant
0

Commented:
Hi,
Is it a limited number of images that you know beforehand? If it's no more than 10 or 20, you could have an array of arrays, each sub-array storing the (e.g) left upper corner points of imaginary sqares around the numbers. If you don't know and can't prepare/"measure" the images beforehand (or if they are hundreds), than you can forget this method.
0

Commented:
Yep, happened again :<
The mask is the same thing more or less. I'm sure it will work ;)
0

Commented:
actually the mask is an image, the same size as the original image that has the same shapes as the original image with or without the numbers) that is used only to detect the position of teh shape on the original image and the sape on the mask is filled with one color. in case of a 10 shape image, you have 11 colors in the mask. pretty much the same principle as in skinning methods using masks ;)
So your idea  tname is different. I will post my solution in 20 minutes or so.
0

Author Commented:
Ohh I have not a for sure number of images but probly at least 100 images will be used. I will use jpgs in  the actuial code.
Thanks
Grant
0

Commented:
>So your idea  tname is different
Ok, I'm relieved! I thought you meant something like a matrix.

0

Commented:
the way I done the mask:
- saved the original image as ACondence_mask.jpg
- opened it in ms paint
- clicked on red, filled in the number 1 shape and then click on colors (menu)-edit colors, then define custom colors and looked at the values of red,gree,blue then wrote in code: colors[1]:=rgb(255,0,0);
- sleected next color, yellow.
- same for all 8 shapes.
- then filled in code colors 9 and 10 with the next colors in line.

basically, you can probably do better creating a small "paint-like" application that will also save the rgb values used to some file (like in this case ACondence.mask) and then the application will load that file and read up all colors rgb values and dinamically compute the array of colors. this will be easier for you since you are having 100+ images; using paint as an intermediary will slow things down quite a bit.
0

Author Commented:
Hey that will work great so i will have a mask for each picture.on form creat. I think I can make a list of say 1 to 20 of rgb colors and for each image use tha samw color scheeme. So i do a differnt image and if it has more than 10 items on it i just add more colors to the mask and on form creat .
This seems like it will work well. Does the above sound right for me to use more and differnt images.
Thanks
Grant
0

Commented:
you should definetly use the same colors for all image masks. that is why I gave an example of 10 colors where the mask only had 8 shapes ;) you can define say 20 colors and only use the first x colors in a mask, where x is the number of shapes. just make sure to use the same colors for the same numbers ;)
0

Author Commented:
Thanks Very much a great Solution.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.