Solved

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

Posted on 2006-11-12
11
579 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
code issue 8 133
Delphi Firemonkey Need Sample for Online Shopping Example. 2 145
Base1 Encode/Decode 3 77
Delphi...Split view - idea? 1 70
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

832 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