Solved

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

Posted on 2006-11-12
11
571 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:ciuly
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 28

Expert Comment

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

Expert Comment

by:ciuly
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:Grant Fullen
Comment Utility
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
Comment Utility
>So your idea  tname is different
Ok, I'm relieved! I thought you meant something like a matrix.

0
 
LVL 28

Accepted Solution

by:
ciuly earned 500 total points
Comment Utility
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
Comment Utility
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:ciuly
Comment Utility
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
Comment Utility
Thanks Very much a great Solution.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now