图像处理中的归一化 [英] normalization in image processing

查看:508
本文介绍了图像处理中的归一化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

图像处理中归一化的正确含义是什么?我用谷歌搜索,但我有不同的定义.我将尝试详细解释每个定义.

核矩阵的归一化

如果将归一化称为矩阵(例如用于卷积滤波器的内核矩阵),则通常将矩阵的每个值除以矩阵值的总和,以便获得矩阵值的总和等于1(如果所有值都大于零).这很有用,因为图像矩阵和我们的内核矩阵之间的卷积会为输出图像提供介于0和原始图像最大值之间的值.但是,如果我们使用sobel矩阵(具有一些负值),这将不再成立,我们必须拉伸输出图像以使所有值都在0到最大值之间.

图像的标准化

我基本上找到标准化的两个定义.第一个是将值切"得太高或太低.即,如果图像矩阵的值为负,则将其设置为零;如果图像矩阵的值大于最大值,则将其设置为最大值.第二个方法是线性拉伸所有值,以使它们适合区间[0,最大值].

解决方案

我将扩展@metsburg的答案.标准化图像(通常是数据矢量)的方法有多种,在不同情况下方便使用:

  • 数据规范化或数据(重新)缩放:数据投影到预定义的范围内(即通常为[0, 1][-1, 1]).当您拥有来自不同格式(或数据集)的数据并且想要对所有数据进行规范化时,这将很有用,因此您可以对它们应用相同的算法.通常执行如下:

    Inew = (I - I.min) * (newmax - newmin)/(I.max - I.min)  + newmin
    

  • 数据标准化是对数据进行标准化的另一种方法(机器学习中的很多),其中均值减去了图像并按其标准差进行了划分.如果您打算将图像用作某种机器学习算法的输入,则该功能特别有用,因为它们中许多都表现得更好,因为它们假定特征具有mean=0,std=1的高斯形式.它可以很容易地执行为:

    Inew = (I - I.mean) / I.std
    

  • 数据拉伸或(使用图像时的直方图拉伸),称为您的选项2.通常,将图像钳制为最小值和最大值,并设置:

    Inew = I
    Inew[I < a] = a
    Inew[I > b] = b
    

    此处,低于a的图像值被设置为a,并且与b相反地发生.通常,将ab的值计算为百分比阈值. a =分隔数据底部1%的阈值,而b =分隔数据顶部1%的阈值.这样,您就可以从图像中删除异常值(噪声) . 这与直方图均衡类似(更简单),预处理步骤.

  • 数据归一化,也可以称为向量相对于范数的归一化( l1规范 l2/欧几里得规范).实际上,这被翻译为:

    Inew = I / ||I||
    

    其中||I||符合I规范.

    如果将范数选择为l1范数,则图像将除以其绝对值的总和,从而使整个图像的总和等于1.如果将范数选择为l2(或欧几里得),则将图像除以I的平方值之和,从而使I的平方值之和等于1.

前3个广泛用于图像(不是3个,因为 scaling standarization 不兼容,但是其中1个或 scaling + streching 标准化+拉伸),最后一个不是那么有用.它通常用作某些统计工具的预处理程序,但是如果您打算使用单个图像,则不会使用它.

What is the correct mean of normalization in image processing? I googled it but i had different definition. I'll try to explain in detail each definition.

Normalization of a kernel matrix

If normalization is referred to a matrix (such as a kernel matrix for convolution filter), usually each value of the matrix is divided by the sum of the values of the matrix in order to have the sum of the values of the matrix equal to one (if all values are greater than zero). This is useful because a convolution between an image matrix and our kernel matrix give an output image with values between 0 and the max value of the original image. But if we use a sobel matrix (that have some negative values) this is not true anymore and we have to stretch the output image in order to have all values between 0 and max value.

Normalization of an image

I basically find two definition of normalization. The first one is to "cut" values too high or too low. i.e. if the image matrix has negative values one set them to zero and if the image matrix has values higher than max value one set them to max values. The second one is to linear stretch all the values in order to fit them into the interval [0, max value].

解决方案

I will extend a bit the answer from @metsburg. There are several ways of normalizing an image (in general, a data vector), which are used at convenience for different cases:

  • Data normalization or data (re-)scaling: the data is projected in to a predefined range (i.e. usually [0, 1] or [-1, 1]). This is useful when you have data from different formats (or datasets) and you want to normalize all of them so you can apply the same algorithms over them. Is usually performed as follows:

    Inew = (I - I.min) * (newmax - newmin)/(I.max - I.min)  + newmin
    

  • Data standarization is another way of normalizing the data (used a lot in machine learning), where the mean is substracted to the image and dividied by its standard deviation. It is specially useful if you are going to use the image as an input for some machine learning algorithm, as many of them perform better as they assume features to have a gaussian form with mean=0,std=1. It can be performed easyly as:

    Inew = (I - I.mean) / I.std
    

  • Data stretching or (histogram stretching when you work with images), is refereed as your option 2. Usually the image is clamped to a minimum and maximum values, setting:

    Inew = I
    Inew[I < a] = a
    Inew[I > b] = b
    

    Here, image values that are lower than a are set to a, and the same happens inversely with b. Usually, values of a and b are calculated as percentage thresholds. a= the threshold that separates bottom 1% of the data and b=the thredhold that separates top 1% of the data. By doing this, you are removing outliers (noise) from the image. This is similar (simpler) to histogram equalization, which is another used preprocessing step.

  • Data normalization, can also be refereed to a normalization of a vector respect to a norm (l1 norm or l2/euclidean norm). This, in practice, is translated as to:

    Inew = I / ||I||
    

    where ||I|| refeers to a norm of I.

    If the norm is choosen to be the l1 norm, the image will be divided by the sum of its absolute values, making the sum of the whole image be equal to 1. If the norm is choosen to be l2 (or euclidean), then image is divided by the sum of the square values of I, making the sum of square values of I be equal to 1.

The first 3 are widely used with images (not the 3 of them, as scaling and standarization are incompatible, but 1 of them or scaling + streching or standarization + stretching), the last one is not that useful. It is usually applied as a preprocess for some statistical tools, but not if you plan to work with a single image.

这篇关于图像处理中的归一化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆