Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I am trying to implement a feature of drawing closed contour that defines my region of interest. I would like to manually draw a contour that encloses some object in a image using my mouse. The contour should be closed at the end, something like ImageJ does. I am wondering if there is any tools, 3rd party libs in C++ can help with this. I know probably OpenCV can be a source, but I am trying to implement something light and easy. So is there anyway to do so? Any pointer is appreciated. Thanks. --Nick
Posted
Comments
Sergey Alexandrovich Kryukov 29-Nov-12 12:50pm    
This problem, in general case, is never light or easy -- just think about it.
--SA
YvesDaoust 30-Nov-12 4:16am    
You should specify whether the contour needs to follow some object edge/outline in the image or just be a freehand path.

First problem is hard; second is trivial.
Nick Tsui 30-Nov-12 9:22am    
Free hand drawing, something like the similar function in ImageJ as I mentioned.
YvesDaoust 30-Nov-12 9:36am    
I don't know how it is in ImageJ.

Capturing the cursor positions is very simple. Just implement a MouseMove event handler and store the coordinates in an array. Implement drawing in the Pain event handler. There is no need for a third party library.
Nick Tsui 30-Nov-12 9:50am    
Sounds good. Is that possible to show the user the line they are going to draw when they are moving their mouse? For example, I have clicked my first point, now I am looking for where to put my second. So it would be nice if the program can show the line that links the first point and the second point, so that the user can have more information to decide where the second point goes.

Look at this sample i did
http://www.codeproject.com/Questions/505546/howplustoplusdrawplusstraightpluslineplushorizonta">On this website


its not in C++ but it shouldn't be too difficult to port
 
Share this answer
 
We used to use PSET (pixel set) command on a picturebox in VB2.

I dont know if that command is still available in a picturebox object but its is pretty basic so I shuold assume its still there.

As far as i can remember the command used go something like.....

MyPictureBox1.Pset(X,Y,Color)
 
Share this answer
 
Comments
Nick Tsui 30-Nov-12 14:59pm    
Does C++ have that feature?
Zaf Khan 30-Nov-12 15:41pm    
Well I couldnt see the PSET method listed as part of the picturebox itself but I think the graphics attribute/property of the picturebox offers a similar/equivalent method.

maybe this page at msdn can help you?
Zaf Khan 30-Nov-12 15:43pm    
Zaf Khan 30-Nov-12 15:45pm    
Well I couldnt see the method PSET listed for the C++ picturebox but the graphics attribute/property of the picture does make the feature available.

Maybe this page at MSDN can help you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900