C#,图像二值化(04)——全局阈值的凯勒算法(Kittler Thresholding)及源程序
1、Kittler算法(最小误差法)概述
最小误差法是 J. Kittler & J. Illingworth 1986年在《MINIMUM ERROR THRESHOLDING》文章中提出的一种基于直方图的阈值分割方法,简称 Kittler 算法。其思想:假设灰度图像由目标和背景组成,且目标和背景满足一混合高斯分布,计算目标和背景的均值、方差,根据最小分类误差思想得到的最小误差目标函数,取目标函数最小时的阈值即为最佳阈值。按此阈值将图像分割为二值图像。
Kittler算法与Otsu方法效果接近,但速度更快,更适宜应用于像素质量较高的图像中。
Kittler算法的中心思想是,计算整幅图像的梯度灰度的平均值,以此平均值做为阈值。
二值算法综述请阅读:
支持函数请阅读:
2、Kittler算法源代码
using System;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Drawing.Imaging;
namespace Legalsoft.Truffer.ImageTools
{
public static partial class BinarizationHelper
{
#region 灰度图像二值化 全局算法 Kittler 算法
/// <summary>
/// Kittler算法
/// </summary>
/// <param name="data"></param>
public static void Kittler_Algorithm(byte[,] data)
{
int height = data.GetLength(0);
int width = data.GetLength(1);
double sumGrads = 0.0;
double sumGrayGrads = 0.0;
for (int y = 1; y < height - 1; y++)
{
for (int x = 1; x < width - 1; x++)
{
double Grads = Math.Max(Math.Abs(data[y - 1, x] - data[y + 1, x]), Math.Abs(data[y, x - 1] - data[y, x + 1]));
sumGrads += Grads;
sumGrayGrads += Grads * (data[y, x]);
}
}
int threshold = (int)(sumGrayGrads / sumGrads);
Threshold_Algorithm(data, threshold);
}
#endregion
}
}
The Kittler binarization method is a classic binarization method based on histogram. ... The idea is: first cut the image into small patches of the same size, and then use the method mentioned in the paper to calculate a local (relative to the entire image) threshold for each small patch, and then use bilateral interpolation
3、Kittler算法的二值化效果以及与基本阈值算法的对比
The Kittler binarization method is a classic binarization method based on histogram. Proposed by J. Kittler in the paper " Minimum Error Thresholding" published in 1986 .
相关文章
- 【彩票】彩票预测算法(一):离散型马尔可夫链模型C#实现
- C#数据Encrypt加密Encrypt解密的算法使用
- c#执行并行任务之Parallel与TaskFactory
- C#数据结构与算法揭秘七
- C#数据结构与算法揭秘二
- C#实现文件数据库
- 揽货最短路径解决方案算法 - C# 蚁群优化算法实现
- 使用C#调用旋风快车和迅雷下载文件 也是C#调用Com的好例子!
- 重新整理数据结构与算法(c#)——算法套路k克鲁斯算法[三十]
- C# 获取今天,昨天,上周,下周,上月,下月等等一些日期格式
- 重新整理数据结构与算法(c#)—— 算法套路动态规划算法[二十六]
- 重新整理数据结构与算法(c#)—— 二叉树排序树[二十二]
- C# 读取Excel中的数据
- [转] C#2010 在TreeView控件下显示路径下所有文件和文件夹
- C# 文件流压缩解压
- C# ExecuteNonQuery()的返回值
- 【彩票】彩票预测算法(一):离散型马尔可夫链模型C#实现
- Atitit.跨语言 java c#.net php js常用的codec encode算法api 兼容性 应该内置到语言里面
- C# WinForm程序的App.Config数据库连接配置文件
- 【转载】C#异常Retry通用类
- C#+无unsafe的非托管大数组(large unmanaged array in c# without 'unsafe' keyword)
- C#操作字符串方法 [万余字总结 · 详细]
- C#简单实现表达式目录树(Expression)
- 【查找算法】二分查找(C# + 递归、非递归和变种形式)