Win8 Metro(C#)数字图像处理--2.74图像凸包计算
2024-09-01 00:18:49
原文:Win8 Metro(C#)数字图像处理--2.74图像凸包计算
/// <summary>
/// Convex Hull compute.
/// </summary>
/// <param name="points">The source image points.</param>
/// <param name="startPoints"></param>
/// <param name="endPoints"></param>
private static void ConvexhullCompute(ref Point[] srcPoints,ref List<Point>startPoints, ref List<Point> endPoints)
{
Point start;
Point end;
double a = 0, b = 0;
int signa = 0, signb = 0;
int max = srcPoints.Length;
double temp = 0.0;
int t = 0;
double tx = 0.0;
for (int i = 0; i < max; i++)
{
start = srcPoints[i];
for (int k = i + 1; k < max; k++)
{
end = srcPoints[k];
if (start.X == end.X)
{
for (int j = 0; j < max; j++)
{
if ((!(signa > 0 && signb > 0)) && (j != i && j != k))
{
t = srcPoints[j].X;
if (t > start.X)
signa++;
if (t < start.X)
signb++;
}
}
}
else
{
a = (double)(end.Y - start.Y) / (double)(end.X - start.X);
b = (double)start.Y - (double)start.X * a;
for (int j = 0; j < max; j++)
{
if ((!(signa > 0 && signb > 0)) && (j != i && j != k))
{
temp = a * (double)srcPoints[j].X + b;
tx = (double)srcPoints[j].Y;
if (temp > tx)
signa++;
if (temp < tx)
signb++;
}
}
}
if (signa * signb == 0)
{
startPoints.Add(start);
endPoints.Add(end);
}
signb = 0;
signa = 0;
}
}
}
最后,分享一个专业的图像处理网站(微像素),里面有很多源代码下载:
最新文章
- git submodule初用
- Netty(三)TCP粘包拆包处理
- ZOJ3792_Romantic Value
- SQL Server 连接超时案例一则
- Adaboost 算法的原理与推导
- CentOS 7 AMD64安装nginx和mysql
- cookie案例-显示用户上次访问网站的时间
- ABBYY FineReader自定义工作区的方法
- Poj(2253),Dijkstra松弛条件的变形
- 【转载】 使用Anemometer基于pt-query-digest将MySQL慢查询可视化
- 在Entity Framework中重用现有的数据库连接字符串
- JDBC基本知识
- Tomcat中Listener的使用范例(转载http://cywhoyi.iteye.com/blog/2075848)
- Zookeeper 安装和配置
- iOS 环信消息撤回
- tomcat 组件研究二--请求过程
- 【转载】OAuth2 流程
- Angular4.x跨域请求
- PHP 获取 IE浏览器版本号
- 探索基于.NET下实现一句话木马之ashx篇