C#,图像二值化(15)——全局阈值的一维最大熵(1D maxent)算法及源程序

1、最大熵(maxent)

最大熵(maxent)方法植根于信息理论,并已成功应用于许多领域,包括物理学和自然语言处理。它创建了一个模型,该模型最好地解释了可用数据,但有一个约束,即在没有任何附加信息的情况下,该模型应该最大化熵。换句话说,该模型通过最大化条件熵来偏好均匀分布。最大熵模型最初由Berger等人(1996)开发,用于自然语言应用,如信息检索和语音识别。Jeon和Manmatha(2004)将该模型用于图像。我们遵循Jeon和Manmatha(2004)将maxent应用于形状分类问题的推导。

Maximum entropy
The maximum entropy (maxent) approach is rooted in information theory and has been successfully applied to many fields including physics and natural language processing. It creates a model that best accounts for the available data but with a constraint that without any additional information the model should maximize entropy. In other words, the model prefers a uniform distribution by maximizing the conditional entropy. The maximum entropy model was originally developed by Berger et al. (1996) for natural language applications such as information retrieval and speech recognition. Jeon and Manmatha (2004) adapted the model for images. We follow the derivation of Jeon and Manmatha (2004) applying maxent to the problem of shape classification.

最大熵原理是一个规则,它允许我们从多个不同的概率分布中选择一个“最佳”,这些概率分布都表示当前的知识状态。它告诉我们,最好的选择是熵最大的那个。

这将是剩余不确定性最大的系统,通过选择它,您可以确保您的分析中没有添加任何额外的偏见或不必要的假设。

我们知道,随着时间的推移,所有系统都趋向于最大熵配置,因此,最大熵分布准确表示系统的可能性高于更有序系统表示的可能性。

The maximum entropy principle is a rule which allows us to choose a ‘best’ from a number of different probability distributions that all express the current state of knowledge. It tells us that the best choice is the one with maximum entropy.

This will be the system with the largest remaining uncertainty, and by choosing it you’re making sure you’re not adding any extra biases or uncalled for assumptions into your analysis.

We know that all systems tend toward maximal entropy configurations over time, so the likelihood that your system is accurately represented by the maximum entropy distribution is higher than the likelihood it would be represented by a more ordered system.
 

C#,图像二值化(15)——全局阈值的一维最大熵(1D maxent)算法及源程序_第1张图片

2、灰度图像二值化,全局算法,一维最大熵的阈值算法源程序

  二值算法综述请阅读:

C#,图像二值化(01)——二值化算法综述与二十三种算法目录https://blog.csdn.net/beijinghorn/article/details/128425225?spm=1001.2014.3001.5502

支持函数请阅读:

C#,图像二值化(02)——用于图像二值化处理的一些基本图像处理函数之C#源代码https://blog.csdn.net/beijinghorn/article/details/128425984?spm=1001.2014.3001.5502

C#,图像二值化(15)——全局阈值的一维最大熵(1D maxent)算法及源程序_第2张图片

using System;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Collections;
using System.Collections.Generic;
using System.Drawing.Imaging;
 
namespace Legalsoft.Truffer.ImageTools
{
    public static partial class BinarizationHelper
    {
        #region 灰度图像二值化 全局算法 一维最大熵

        /// 
        /// 一维最大熵
        /// 
        /// 
        /// 
        public static int Maxium_Entropy_1D_Threshold(int[] histogram)
        {
            int MinValue = Histogram_Left(histogram);
            int MaxValue = Histogram_Right(histogram);
            double[] HistGramD = Histogram_Normalize(histogram);

            int Threshold = 0;
            double MaxEntropy = double.MinValue;
            for (int i = MinValue + 1; i < MaxValue; i++)
            {
                double SumIntegral = 0.0;
                for (int j = MinValue; j <= i; j++)
                {
                    SumIntegral += HistGramD[j];
                }

                double EntropyBack = 0.0;
                for (int j = MinValue; j <= i; j++)
                {
                    EntropyBack += (-HistGramD[j] / SumIntegral * Math.Log(HistGramD[j] / SumIntegral));
                }

                double EntropyFore = 0.0;
                for (int j = i + 1; j <= MaxValue; j++)
                {
                    EntropyFore += (-HistGramD[j] / (1.0 - SumIntegral) * Math.Log(HistGramD[j] / (1.0 - SumIntegral)));
                }

                if ((EntropyBack + EntropyFore) > MaxEntropy)
                {
                    Threshold = i;
                    MaxEntropy = EntropyBack + EntropyFore;
                }
            }
            return Threshold;
        }

        public static void Maxium_Entropy_1D_Algorithm(byte[,] data)
        {
            int[] histogram = Gray_Histogram(data);
            int threshold = Maxium_Entropy_1D_Threshold(histogram);
            Threshold_Algorithm(data, threshold);
        }

        #endregion

    }
}
 

3、灰度图像二值化,全局算法,一维最大熵的阈值算法计算效果

C#,图像二值化(15)——全局阈值的一维最大熵(1D maxent)算法及源程序_第3张图片

效果很一般一般一般。 

你可能感兴趣的:(C#算法演义,Algorithm,Recipes,C#实用代码,Coding,Recipes,算法,计算机视觉,c#,图像处理)