資源簡介
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#版
評論
共有 條評論