资源简介
C#开发,二值化数字图像,用Freeman链码标定图像边界,然后计算图像矩
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ImageProcess
{
public class Calculate
{
private IList Lines = null;
public Calculate(IList Lines)
{
this.Lines = Lines;
}
//得到每行计算结果
public void Cal()
{
foreach( LineInfo item in Lines )
{
double s1 = 0;
double s2 = 0;
double s3 = 0;
double d = item.width;
int line = item.line;
int x=item.x;
int y=item.y;
s1 = d * d / 2 - d / 2;
s2 = d * d * d / 3 - d * d / 2 + d / 6;
s3 = d * d * d * d / 4 - d * d * d / 2 + d * d / 4;
item.s1 = s1;
item.s2 = s2;
item.s3 = s3;
item.M00 = d;
item.M01 = d * y;
item.M02 = d * y * y;
item.M03 = d * y * y * y;
item.M10 = d * x + s1;
item.M11 = y * item.M10;
item.M12 = y * y * item.M10;
item.M20 = d * x * x + 2 * s1 * x + s2;
item.M21 = y * item.M20;
item.M30 = d * x * x * x + 3 * s1 * x * x + 3 * s2 * x + s3;
}
}
}
}
- 上一篇:C#UDP屏幕监控
- 下一篇:新浪新闻RSS阅读器C#版
评论
共有 条评论