使用锚点在图像中选择感兴趣的多边形区域 [英] Selecting polygon region of interest in image with anchors

查看:129
本文介绍了使用锚点在图像中选择感兴趣的多边形区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我正在编写一个简单的图像处理程序.我在灰度图像中选择一个区域,并生成像素值的直方图.要求之一是用户应该能够选择图像中感兴趣的多边形区域.也就是说,用户在图像上单击了多次,并且每次在图像上出现一个锚点,并通过一条线连接到先前的锚点.用户可以单击多次,直到绘制任意形状并关闭多边形为止.

创建多边形后,用户应该能够修改每个锚点.例如,这类似于MS Power Point中的折线工具.

完成用户操作后,我就有了代码来仅对多边形区域内的像素进行分析和报告.

这是一个标准的Windows应用程序.

我对如何从头开始创建这样的东西有一个想法.但是我想知道是否有人知道已经存在的解决方案.似乎在Google等上找不到任何内容.

预先感谢您的支持.
Dmitry

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

推荐答案

在过去,有一个涂鸦"示例程序向您展示如何在MFC下通过鼠标交互来处理图形.它仍然存在,但是您应该专注于图形交互的原理,而不是额外的技术性.

无论如何,您需要做的是:
-设计允许用户使用鼠标定义和拖动多边形的场景(点击和鼠标移动的顺序);
-实施(部分)多边形和锚点的绘制;这是通过绘制函数(例如Graphics.DrawLine)在Paint事件处理程序中完成的;
-使用MouseMove,MouseDown ...事件处理程序来监视光标位置以及鼠标按钮状态;要选择"一个顶点,您将需要计算光标和所有顶点之间的最短距离.

这基本上就是您所需要的.表单设计器将帮助您创建所需的事件处理程序.

您还可以在此处获得一些启发: http://www.vb-helper.com/howto_net_polygon_grab_handles.html [ ^ ]
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[^]


这篇关于使用锚点在图像中选择感兴趣的多边形区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆