Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: graphics VB.NET Forms , +
Hello,
 
I am writing a simple image processing program. I select a region in an grey scale image and produce a histogram of pixel values. One of the requirements is that the user should be able to select polygon regions of interest in the image. That is, the user clicks multiple times on the image, and each time, an anchor appears on the image that connects with a line to the previous anchor. The user can click multiple times until he draws any arbitrary shape and closes the polygon.
 
After creating the polygon, the user should be able to modify each anchor. This would be similar to a the poly-line tools in MS Power Point, for example.
 
When the user is done, I have code to analyze and report on just the pixels inside the polygon region.
 
This is a standard Windows Application.
 
I have an idea about how to create such a thing from scratch. But I was wondering if anyone knew of a solution that already exists. Can't seem to find anything on google, etc.
 
Thank you in advance for your support.
Dmitry
Posted 3-Aug-11 8:43am
Edited 3-Aug-11 9:32am
v3
Comments
SAKryukov at 3-Aug-11 14:06pm
   
What "image processing". Add a proper tag: WPF, Forms, ASP.NET, what?
--SA
Member 8133819 at 3-Aug-11 14:33pm
   
SAKryukov,
 
Thank you for your comment. I clarified my original post above. I am writing a windows application in VB.NET. The purpose of it is to select poly-line regions of an grey-scale image and produce a histogram of the pixels. However, the selection should be editable after the fact.
 
Thanks,
Dmitry

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

In the old days there existed a "scribble" sample program to show you how to handle drawing with mouse interaction under MFC. It is still around, but you should focus on the principles of graphical interaction and not on extra technicalities.
 
Anyway, what you need to do is:
- design the scenario that allows the user to define and drag the polygon with the mouse (sequence of clicks and mouse movements);
- implement the drawing of the (partial) polygon and anchors; this is done in the Paint event handler, by means of the drawing functions (such as Graphics.DrawLine);
- use the MouseMove, MouseDown... event handlers to monitor the cursor positions as well as mouse button state; to "select" a vertex, you will need to compute the shortest distance between the cursor and all vertices.
 
That is essentially all you need. The Form Designer will help you create the required event handlers.
 
You can also get some inspiration here: http://www.vb-helper.com/howto_net_polygon_grab_handles.html[^]
  Permalink  
v3

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

  Print Answers RSS
0 BillWoodruff 330
1 Mathew Soji 309
2 Maciej Los 295
3 DamithSL 225
4 Afzaal Ahmad Zeeshan 217
0 OriginalGriff 6,369
1 Sergey Alexandrovich Kryukov 5,973
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 4,025


Advertise | Privacy | Mobile
Web03 | 2.8.1411019.1 | Last Updated 3 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100