归一化

来源:互联网 发布:哪里有卖淘宝店铺出售 编辑:程序博客网 时间:2024/05/17 08:34

opencv 中提供的归一化函数

C++: void normalize(const InputArray src, OutputArray dst, double alpha=1, double beta=0, int normType=NORM_L2, int rtype=-1, InputArray mask=noArray())C++: void normalize(const SparseMat& src, SparseMat& dst, double alpha, int normType)

Parameters:
src – Source array.
dst – Destination array of the same size as src .
alpha – Norm value to normalize to or the lower range boundary in case of the range normalization.
beta – Upper range boundary in case ofthe range normalization. It is not used for the norm normalization.
normType – Normalization type. See the details below.
rtype – When the parameter is negative, the destination array has the same type as src. Otherwise, it has the same number of channels as src and the depth =CV_MAT_DEPTH(rtype) .
mask – Optional operation mask.
The functions normalize scale and shift the source array elements so that

这里写图片描述

(where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that

这里写图片描述

when normType=NORM_MINMAX (for dense arrays only). The optional mask specifies a sub-array to be normalized. This means that the norm or min-n-max are computed over the sub-array, and then this sub-array is modified to be normalized. If you want to only use the mask to compute the norm or min-max but modify the whole array, you can use norm() and Mat::convertTo().

In case of sparse matrices, only the non-zero values are analyzed and transformed. Because of this, the range transformation for sparse matrices is not allowed since it can shift the zero level.

例:

normalize(r_hist, r_hist, 0, histImage.rows, NORM_MINMAX, -1, Mat() );

该函数接受下列参数:

r_hist: 输入数组
r_hist: 归一化后的输出数组(支持原地计算)
0 及 histImage.rows: 这里,它们是归一化 r_hist 之后的取值极限
NORM_MINMAX: 归一化方法 (例中指定的方法将数值缩放到以上指定范围)
-1: 指示归一化后的输出数组与输入数组同类型
Mat(): 可选的掩码

0 0
原创粉丝点击