原文: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;
}
}
}

最后,分享一个专业的图像处理网站(微像素),里面有很多源代码下载:

最新文章

  1. git submodule初用
  2. Netty(三)TCP粘包拆包处理
  3. ZOJ3792_Romantic Value
  4. SQL Server 连接超时案例一则
  5. Adaboost 算法的原理与推导
  6. CentOS 7 AMD64安装nginx和mysql
  7. cookie案例-显示用户上次访问网站的时间
  8. ABBYY FineReader自定义工作区的方法
  9. Poj(2253),Dijkstra松弛条件的变形
  10. 【转载】 使用Anemometer基于pt-query-digest将MySQL慢查询可视化
  11. 在Entity Framework中重用现有的数据库连接字符串
  12. JDBC基本知识
  13. Tomcat中Listener的使用范例(转载http://cywhoyi.iteye.com/blog/2075848)
  14. Zookeeper 安装和配置
  15. iOS 环信消息撤回
  16. tomcat 组件研究二--请求过程
  17. 【转载】OAuth2 流程
  18. Angular4.x跨域请求
  19. PHP 获取 IE浏览器版本号
  20. 探索基于.NET下实现一句话木马之ashx篇

热门文章

  1. ArcEngine 图层标注 (根据字段、角度)
  2. 【u210】kfc
  3. 【poj2528】Mayor's posters
  4. [网络管理]windows server backup
  5. [React] Normalize Events with Reacts Synthetic Event System
  6. SQL Server高速生成SQL增删改查语句
  7. PyCharm 重构(refactor)快捷键
  8. PCI的imagework已由freeview软件代替
  9. 【t017】YL杯超级篮球赛
  10. AsyncTask下载图片