首页 最新 热门 推荐

  • 首页
  • 最新
  • 热门
  • 推荐

opencv中归一化函数normalize()的原理讲解

  • 23-09-22 20:02
  • 4409
  • 10245
blog.csdn.net

1. 归一化

归一化就是要把需要处理的数据经过处理后(通过某种算法)限制在你需要的一定范围内。

首先归一化是为了后面数据处理的方便,其次是保证程序运行时收敛加快。归一化的具体作用是归纳统一样本的统计分布性。归一化在0-1之间是统计的概率分布,归一化在某个区间上是统计的坐标分布。归一化有同一、统一和合一的意思。

归一化的目的,是使得没有可比性的数据变得具有可比性,同时又保持相比较的两个数据之间的相对关系,如大小关系;或是为了作图,原来很难在一张图上作出来,归一化后就可以很方便的给出图上的相对位置等。

2. opencv中的归一化函数normalize()

opencv文档中的介绍如下:

C++: void normalize(InputArray src, InputOutputArray dst, double alpha=1, double beta=0, int norm_type=NORM_L2, int dtype=-1, InputArray mask=noArray() )

C++: void normalize(const SparseMat& src, SparseMat& dst, double alpha, int normType)

Python: cv2.normalize(src[, dst[, alpha[, beta[, norm_type[, dtype[, mask]]]]]]) → dst

Parameters:
  • src – input array.
  • dst – output 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 of the range normalization; it is not used for the norm normalization.
  • normType – normalization type (see the details below).
  • dtype – when negative, the output array has the same type as src; otherwise, it has the same number of channels as src and the depth =CV_MAT_DEPTH(dtype).
  • mask – optional operation mask.

The functions normalize scale and shift the input 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 calculated over the sub-array, and then this sub-array is modified to be normalized. If you want to only use the mask to calculate 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.

从上面可以看成,opencv提供了四种不同的归一化方式,分别为NORM_INF, NORM_MINMAX,NORM_L1和NORM_L2。下面分别解释一下各自代表的含义及归一化公式。

NORM_MINMAX:数组的数值被平移或缩放到一个指定的范围,线性归一化。

比如归一化到(min,max)范围内:

NORM_INF: 归一化数组的(切比雪夫距离)L∞范数(绝对值的最大值)

NORM_L1 :  归一化数组的(曼哈顿距离)L1-范数(和的绝对值)

NORM_L2: 归一化数组的(欧几里德距离)L2-范数

而其中的dtype为负数时,输出数组的type与输入数组的type相同;

否则,输出数组与输入数组只是通道数相同,而tpye=CV_MAT_DEPTH(dtype).

文章知识点与官方知识档案匹配,可进一步学习相关知识
OpenCV技能树首页概览20473 人正在系统学习中
注:本文转载自blog.csdn.net的kuweicai的文章"https://blog.csdn.net/kuweicai/article/details/78988886"。版权归原作者所有,此博客不拥有其著作权,亦不承担相应法律责任。如有侵权,请联系我们删除。
复制链接
复制链接
相关推荐
发表评论
登录后才能发表评论和回复 注册

/ 登录

评论记录:

未查询到任何数据!
回复评论:

分类栏目

后端 (14832) 前端 (14280) 移动开发 (3760) 编程语言 (3851) Java (3904) Python (3298) 人工智能 (10119) AIGC (2810) 大数据 (3499) 数据库 (3945) 数据结构与算法 (3757) 音视频 (2669) 云原生 (3145) 云平台 (2965) 前沿技术 (2993) 开源 (2160) 小程序 (2860) 运维 (2533) 服务器 (2698) 操作系统 (2325) 硬件开发 (2492) 嵌入式 (2955) 微软技术 (2769) 软件工程 (2056) 测试 (2865) 网络空间安全 (2948) 网络与通信 (2797) 用户体验设计 (2592) 学习和成长 (2593) 搜索 (2744) 开发工具 (7108) 游戏 (2829) HarmonyOS (2935) 区块链 (2782) 数学 (3112) 3C硬件 (2759) 资讯 (2909) Android (4709) iOS (1850) 代码人生 (3043) 阅读 (2841)

热门文章

101
推荐
关于我们 隐私政策 免责声明 联系我们
Copyright © 2020-2024 蚁人论坛 (iYenn.com) All Rights Reserved.
Scroll to Top