当前位置: 首页 > java >正文

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

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).

http://www.xdnf.cn/news/11267.html

相关文章:

  • favicon是什么,怎么用?
  • 国外最好的BT站点
  • Turbine实战(上)
  • FontCreator字体精简工具快速使用指南
  • Raptor-冒泡排序法
  • 大漠插件7.2422
  • webm转换mp4,四种转换方法任你选!
  • 计算机网络 — UDP协议(看这一篇就可以
  • JNI原理及常用方法概述
  • Sql中的like的用法
  • 添加Microsoft Office Document Image Writer 打印机
  • gcta计算FST、python绘图
  • latex编辑小常识
  • oracle递归函数
  • 企业高性能web服务器【Nginx详解】
  • FusionCharts Free 报表工具
  • 开发者必去的10大国内网站推荐
  • 黄页
  • 微信公众号分销商城源码系统+多商户入驻+互动直播+整点秒杀 带部署教程
  • 关于asp.net的富文本框编辑器,DotNetTextBox的用法详解
  • JQuery lhgdialog使用
  • 论坛博客常用代码合集
  • GET和POST史上最全总结
  • PropertyUtils的使用
  • Elasticsearch 技术分析(九):全文搜索引擎Elasticsearch,这篇文章给讲透了!
  • 粉丝答疑:如何实现高效免杀?
  • 智能聊天助手:数据分析的新兴英雄
  • 千兆光模块和万兆光模块的安装和维护指南
  • 使用U盘安装Fedora14 32bit操作系统(参考自www.osyunwei.com)
  • 如何给网页和代码做HTML加密?