Solved

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

Posted on 2006-11-12
11
582 Views
Last Modified: 2010-04-05
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
Comment
Question by:Grant Fullen
  • 4
  • 4
  • 3
11 Comments
 
LVL 28

Expert Comment

by:2266180
ID: 17925392
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 Comment

by:Grant Fullen
ID: 17925402
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
 
LVL 28

Expert Comment

by:TName
ID: 17925453
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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 28

Expert Comment

by:TName
ID: 17925466
Yep, happened again :<
The mask is the same thing more or less. I'm sure it will work ;)
0
 
LVL 28

Expert Comment

by:2266180
ID: 17925474
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 Comment

by:Grant Fullen
ID: 17925485
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
 
LVL 28

Expert Comment

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

0
 
LVL 28

Accepted Solution

by:
2266180 earned 500 total points
ID: 17925649
demo here: http://www.ciuly.com/delphi/imageShapeClickedWithMask.zip
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 Comment

by:Grant Fullen
ID: 17925751
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
 
LVL 28

Expert Comment

by:2266180
ID: 17925843
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 Comment

by:Grant Fullen
ID: 17925886
Thanks Very much a great Solution.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question