zl程序教程

您现在的位置是:首页 >  后端

当前栏目

C#,图像二值化(17)——全局阈值的ISODATA算法(亦称作InterMeans法)及其源程序

c#算法 图像 及其 17 全局 阈值 源程序
2023-09-11 14:15:48 时间

 

  二值算法综述请阅读:

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

1、ISODATA算法

原文:

Ridler, TW & Calvard, S (1978), "Picture thresholding using an iterative selection methodhttp://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=4310039

ISO数据

基于isodata算法的迭代程序:

Ridler,TW&Calvard,S(1978),“使用迭代选择方法的图像阈值”,IEEE系统、人和控制论汇刊8:630-632

该过程通过采用初始阈值将图像划分为对象和背景,然后计算阈值或阈值以下的像素和阈值以上的像素的平均值。计算这两个值的平均值,增加阈值并重复该过程,直到阈值大于复合平均值。即,

阈值=(平均背景+平均对象)/2。

该方法有几种实现方式。请参见源代码以获取更多注释。

IsoData
Iterative procedure based on the isodata algorithm of:

Ridler, TW & Calvard, S (1978), "Picture thresholding using an iterative selection method", IEEE Transactions on Systems, Man and Cybernetics 8: 630-632
The procedure divides the image into object and background by taking an initial threshold, then the averages of the pixels at or below the threshold and pixels above are computed. The averages of those two values are computed, the threshold is incremented and the process is repeated until the threshold is larger than the composite average. That is,

threshold = (average background + average objects)/2. 
Several implementations of this method exist. See the source code for further comments.
 

在农业信息领域,植物叶片病害的检测对农民的生活和环境都非常重要。为了提高植物叶病检测的准确性并减少图像处理时间,本研究提出了改进的K均值++聚类和均值间阈值方法。所提出的算法用于在两个不同的数据库中训练和测试植物叶片图像中的疾病。在所提出的方法中,将基于不同的阈值来选择中间均值算法。阈值的最佳值,即中间均值算法,将有助于提高植物叶片图像中疾病分类的准确性和速度。这种方法也将用于植物叶子的不可见图像。植物叶病检测的实验结果达到了98.10%的平均检测准确率。与基于标准K-均值聚类的结果相比,当前方法给出了23.20%左右的更好结果。所提出的算法比用于检测植物叶病的标准算法更有效,以及计算机计算能力中cots的减少。

In the field of agricultural information, the plant leaf disease detection is highly important for both farmer life and environment. To improve the accuracy of plant leaf disease detection and reduce the image processing time, the improved K‒mean++ clustering and intermeans thresholding method are proposed in this study. The proposed algorithms are used for training and testing diseases in plant leaf images in two different databases. Of the proposed methods, the intermeans algorithm will be selected based on different thresholding values. The optimal value of thresholding-i.e., the intermeans algorithm-will help increase the accuracy and speed of classifying diseases in plant leaf images. This method will be also used with unseen images of plant leaf. The experimental result of the detection of plant leaf diseases achieves an average detection accuracy of 98.10%. When compared with the results based on standard K‒mean clustering, the current method gives better results around 23.20%. The proposed algorithm is more effective than the standard algorithms for detecting plant leaf diseases, as well as the reduction in cots in the computational power of computers.

INTERMEANS ITER算法细节

一种迭代算法,其结果与OTSU算法相似

计算强度低于OTSU

算法从t的初始猜测开始

定义两类的均值μt和νt

设置t=[(μt+νt)/2]并重新计算μt和νt。

重复,直到t在两次连续迭代中具有相同的值

获得的t可能强烈依赖于其初始值

如果对象和背景占据可比较的区域,请使用平均值

如果对象与背景相比较小,请使用INTERMODES。

工具书类

T、 Ridler和S.Calvard,使用迭代选择方法的图像阈值,IEEE Trans。系统人网络。,第8卷,第630-6321978页。

H、 J.Trussell,评论?使用迭代选择方法的图像阈值处理?,IEEE Trans。系统人网络。,第9卷,第311页,1979年。

Details of INTERMEANS ITER algorithm
An iterative algorithm that gives similar results as the OTSU algorithm
Computationally less intensive than OTSU
The algorithm starts with an initial guess for t
Define the means μt and νt of the two classes
Set t = [(μt + νt)/2] and recalculate μt and νt.
Repeat until t has the same value in two consecutive iterations
The obtained t may strongly depend on its initial value
If the objects and background occupy comparable areas, use MEAN
If the objects are small compared to the background, use INTERMODES.
References

T. Ridler and S. Calvard, Picture thresholding using an iterative selection method, IEEE Trans. Systems Man Cybernet., vol. 8, pp. 630-632, 1978.
H. J. Trussell, Comments on ?Picture thresholding using an iterative selection method?, IEEE Trans. Systems Man Cybernet., vol. 9, p. 311, 1979.
Acknowledgements Based on the HistThresh Toolbox by Antti Niemistö, Tampere University of Technology, Finland
 

2、ISODATA算法源程序

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 灰度图像二值化 全局算法 ISODATA法 

        /// <summary>
        /// ISODATA(也叫做intermeans法)
        /// </summary>
        /// <param name="histogram"></param>
        /// <returns></returns>
        public static int IsoData_Threshold(int[] histogram)
        {
            int g = Histogram_Left(histogram) + 1;
            while (true)
            {
                int w = 0;
                int totl = 0;
                for (int i = 0; i < g; i++)
                {
                    totl = totl + histogram[i];
                    w = w + (histogram[i] * i);
                }
                int h = 0;
                int toth = 0;
                for (int i = g + 1; i < histogram.Length; i++)
                {
                    toth += histogram[i];
                    h += (histogram[i] * i);
                }
                if (totl > 0 && toth > 0)
                {
                    w /= totl;
                    h /= toth;
                    if (g == (int)Math.Round((w + h) / 2.0))
                    {
                        break;
                    }
                }
                g++;
                if (g > (histogram.Length - 2))
                {
                    return 0;
                }
            }
            return g;
        }


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

        #endregion

    }
}
 

3、ISODATA算法程序计算效果