C#,图像二值化(24)——局部阈值算法的NiBlack算法及源程序

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

1、局部阈值算法的NiBlack算法

摘要-医学图像的处理最为复杂人和计算机。磁性捐赠的脑组织共振成像MRI在许多领域是非常重要的问题例如手术和治疗。最常见的分割图像的最简单方法是使用阈值。在这项工作中我们提出了一个有效的实现阈值并给出详细的比较了现有的局部阈值算法。

Niblack阈值算法在预处理的输入MRI图像。输出结果如下根据区域不均匀性质量度量进行处理以及

高效实施的质量。我们的实施是适用于处理MR脑图像分割对象的交互式平滑边界。

关键词-磁共振成像阈值Niblack区域不均匀性

一、 引言

属于对象的像素的灰度级为与像素的灰度级完全不同属于背景在图像的许多应用中处理。阈值处理变得简单但将前景对象与出身背景我们可以将图像中的像素分成两个主要群体根据其灰度等级。这些灰度级可以用作“检测器”以区分背景和对象被视为前景图像[1]。在这两个主要颜色之间选择一个灰度级

灰度级组将作为阈值区分两组对象和背景。图像分割由边界等执行检测或区域相关技术。但是阈值技术更加完善、简单广泛使用[2]。不同的二值化方法执行以评估不同类型的数据。这个在灰度级中使用局部自适应二值化方法低对比度、背景强度变化的图像以及噪声的存在。Niblack的方法用于灰度图像中的阈值处理效果更好但它仍然是对其进行了修改以获得更好的结果[3]。在这项工作中Niblock算法的输入数据为在一些预处理下增强输出数据。这个MRI脑图像自然具有低对比度。这低对比度图像也得到增强结果从背景分析对象。当地人直方图均衡对输入图像进行了增强[12][13]. 直方图均衡生成灰度图。它更改图像的直方图并重新排列所有像素值尽可能接近用户指定的期望值直方图。直方图均衡丰富了较低的局部对比度以获得较高的对比度。本文的组织结构如下第二节为目的是呈现关于图像阈值的信息。详细解释了局部自适应阈值技术在第三节中第四节侧重于Niblack算法的实现。视觉结果和第四节的质量度量结果在第节中讨论五、 最后第六节包含结论。

二、阈值

简单地阈值的基本函数[5]创建通过旋转所有像素从灰度级图像中提取二值图像

低于某个阈值为零且所有像素高于该阈值阈值设置为一[1][5]。如果gxy是如果fxyT在某个全局阈值T时等于1否则为零[1]。阈值技术一般可分为两类如全局阈值和局部阈值阈值。全局阈值方法考虑单个强度阈值。局部阈值方法计算图像中每个像素的阈值其附近的内容[13]。它认为图像中所有强度级别的存在。所以当地人阈值方法通常对低质量图像[3]。我们将阈值方法分组根据他们利用的信息。直方图基于形状的方法该方法使用了波峰、波谷并分析平滑直方图的曲率。

基于聚类的方法在灰度级样本分为两部分作为背景和前景对象。基于熵的方法导致使用原始数据之间的交叉熵的算法以及二值化图像、前景的熵和背景区域[3]、[4]。基于对象属性的方法搜索灰度级和二值化图像如边缘重合、模糊形状相似性空间方法使用了像素和/或高阶概率分布。地方的方法使每个像素上的阈值适应本地图像特征[4]。

Abstract— Medical images are most complicated to process by

human and computer. Brain tissue donated by magnetic

resonance imaging (MRI) is very important issue in many

applications such as surgery and treatments. Most common

and simplest approach to segment an image is using

thresholding. In this work we present an efficient

implementation for threshoding and give a detailed

comparison of some existing local thresholding algorithm.

Niblack thresholding algorithm is implemented on

preprocessed input MRI image. The output results are

processed under Region Nonuniformity quality metrics and

the quality of efficient implementation. Our implementation is

suitable for processing the MR brain images, making

interactive smooth boundaries to the segmented object.

Keywords— Magnetic resonance imaging, thresholding,

Niblack, Region Nonuniformity

I. INTRODUCTION

The gray levels of pixels belonging to the object are

entirely different from the gray levels of the pixels

belonging to the background, in many applications of image

processing. Thresholding becomes then a simple but

effective tool to separate those foreground objects from the

background. We can divide the pixels in the image into two

major groups, according to their gray-level. These graylevels may serve as “detectors” to distinguish between

background and objects is considering as foreground in the

image [1]. Select a gray-level between those two major

gray-level groups, which will serve as a threshold to

distinguish the two groups (objects and background).

Image segmentation is performed by such as boundary

detection or region dependent techniques. But the

thresholding techniques are more perfect, simple and

widely used [2]. Different binarization methods have been

performed to evaluate for different types of data. The

locally adaptive binarization method is used in gray scale

images with low contrast, Varity of background intensity

and presence of noise. Niblack’s method was found for

better thresholding in gray scale image, but still it has been

modified for fine and better result [3].

In this work the input data of the Niblock algorithm is

under some preprocess for enhanced the output data. The

MRI brain images are naturally having low contrast. This

low contrast images also enhanced and produce a better

result to analysis the object from the background. The Local

Histogram Equalization is enhanced the input image [12],

[13]. Histogram Equalization generates a gray map. It

changes the histogram of an image and rearranges all pixels

values to be as close as possible to a user specified desired

histogram. Histogram Equalization enriches the areas of

lower local contrast to gain a higher contrast.

This paper is organized as follows, section II is for the

purpose of presenting information about image thresholding.

Local adaptive thresholding technique is explained detailed

in section III. Section IV focused the efficient

implementation of Niblack algorithm. Visual results and

quality metric results of section IV are discussed in section

V. Finally section VI contains the conclusion.

II. THRESHOLDING

Simply the basic function [5] for thresholding creates the

binary image from gray level ones by turning all pixels

below some threshold to zero and all pixels above that

threshold to one [1],[5]. If g(x, y) is a threshold version of

f(x, y) at some global threshold T. g is equal to 1 if f(x, y) T

and zero otherwise [1].

Thresholding techniques can be classified generally into

two categories like Global thresholding and Local

thresholding. Global thresholding methods consider a single

intensity threshold value. Local thresholding methods

compute a threshold for each pixel in the image on the basis

of the content in its neighbourhood [13]. It considers

presences of all intensity level in the image. So the local

thresholding methods generally perform better for low

quality images [3].

We categorize the thresholding methods in groups

according to the information they are exploiting. Histogram

shape-based methods, this method used the peaks, valleys

and curvatures of the smoothed histogram are analyzed.

Clustering-based methods perform where the gray-level

samples are clustered in two parts as background and

foreground (object). Entropy-based methods result in

algorithms that use the cross-entropy between the original

and binarized image, the entropy of the foreground and

background regions [3], [4]. Object attribute-based methods;

search a similarity measure between the gray-level and the

binarized images, such as edge coincidence, fuzzy shape

similarity. The spatial methods use correlation between

pixels and/or higher-order probability distribution. Local

methods adapt the threshold value on each pixel to the local

image characteristics [4].

2、局部阈值算法的NiBlack算法源程序

二值算法综述请阅读

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

namespace Legalsoft.Truffer.Binarization
{
public static partial class BinarizationHelper
{

    #region 灰度图像二值化 局部算法 NiBlack 算法

    /// <summary>
    /// 局部算法
    /// 图像二值化的 NiBlack 算法
    /// https://blog.csdn.net/lucayhaozi/article/details/9967963
    /// </summary>
    /// <param name="data">灰度化后的图像byte数组</param>
    /// <param name="k"></param>
    public static void Niblack_Algorithm(byte[,] data, double k = -0.1)
    {
        int height = data.GetLength(0);
        int width = data.GetLength(1);

        int Niblack_s = Math.Max(5, width / 32);
        int Niblack_q = Math.Max(5, height / 32);

        byte[,] dump = (byte[,])data.Clone();
        for (int y = 0; y < height; y++)
        {
            for (int x = 0; x < width; x++)
            {
                int begin_y = Math.Max(0, y - Niblack_q);
                int begin_x = Math.Max(0, x - Niblack_s);
                int end_y = Math.Min(height, y + Niblack_q);
                int end_x = Math.Min(width, x + Niblack_s);
                //if (begin_y < 0) begin_y = 0;
                //if (begin_x < 0) begin_x = 0;
                //if (end_y > height) end_y = height;
                //if (end_x > width) end_x = width;

                //该领域内总的像素点数
                double mean = 0.0;
                int total = (end_y - begin_y) * (end_x - begin_x);
                for (int yy = begin_y; yy < end_y; yy++)
                {
                    for (int xx = begin_x; xx < end_x; xx++)
                    {
                        mean += dump[yy, xx];
                    }
                }
                //计算在该小领域内灰度值总和
                //该领域的平均灰度
                mean /= (double)total;

                double std_error = 0.0;
                for (int yy = begin_y; yy < end_y; yy++)
                {
                    for (int xx = begin_x; xx < end_x; xx++)
                    {
                        std_error += (mean - dump[yy, xx]) * (mean - dump[yy, xx]);
                        //std += sq;
                    }
                }
                //求出该领域内总的方差和
                std_error /= (double)total;
                //求出标准差
                std_error = (Math.Abs(std_error) < float.Epsilon) ? 0.0 : Math.Sqrt(std_error);

                //求出所得到的的阈值
                double threshold = mean + k * std_error;
                data[y, x] = (byte)((dump[y, x] > threshold) ? 255 : 0);
            }
        }
    }

    #endregion

}
}

3、局部阈值算法的NiBlack算法及源程序计算效果

POWER BY 315SOFT.COM & TRUFFER.CN

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6