Matlab到OpenCV转换的示例 [英] Examples of Matlab to OpenCV conversions

查看:382
本文介绍了Matlab到OpenCV转换的示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时候我不得不将一些Matlab代码移植到OpenCV。

From time to time I have to port some Matlab Code to OpenCV.

几乎总是有一种方法可以做到,并在OpenCV中有一个合适的函数。但是它并不总是很容易找到。

Almost always there is a way to do it and an appropriate function in OpenCV. Nevertheless its not always easy to find.

因此,我想开始这个摘要找到和收集Matlab和OpenCV之间的一些等价物。

Therefore I would like to start this summary to find and gather some equivalents between Matlab and OpenCV.

我使用Matlab函数作为标题,并附加其描述从Matlab帮助。

I use the Matlab function as heading and append its description from Matlab help. Afterwards a OpenCV example or links to solutions are appreciated.

推荐答案

Repmat



复制和平铺数组。 B = repmat(A,M,N)创建由A的副本的M乘N平铺组成的大矩阵B.B的大小是[size(A,1)* M,size(A,2) * N]。语句repmat(A,N)创建N乘N平铺。

Repmat

Replicate and tile an array. B = repmat(A,M,N) creates a large matrix B consisting of an M-by-N tiling of copies of A. The size of B is [size(A,1)*M, size(A,2)*N]. The statement repmat(A,N) creates an N-by-N tiling.

B = repeat(A,M,N)

B = repeat(A, M, N)

OpenCV文档

非零元素的索引。 I = find(X)返回对应于数组X的非零项的线性索引.X可以是逻辑表达式。使用IND2SUB(SIZE(X),I)从线性指数I计算多个下标。

Find indices of nonzero elements. I = find(X) returns the linear indices corresponding to the nonzero entries of the array X. X may be a logical expression. Use IND2SUB(SIZE(X),I) to calculate multiple subscripts from the linear indices I.

Similar to Matlab's find

二维卷积。如果[ma,na] = size(A),[mb,nb] = size(B),[mc,nc] =大小(C),则mc = max([ma + mb-1,ma,mb])和nc = max([na + nb-1,na,nb])。

Two dimensional convolution. C = conv2(A, B) performs the 2-D convolution of matrices A and B. If [ma,na] = size(A), [mb,nb] = size(B), and [mc,nc] = size(C), then mc = max([ma+mb-1,ma,mb]) and nc = max([na+nb-1,na,nb]).

与Conv2类似

缩放数据并显示为图像。

Scale data and display as image. imagesc(...) is the same as IMAGE(...) except the data is scaled to use the full colormap.

SO Imagesc

多维图像的ND滤波。 B = imfilter(A,H)用多维滤波器H来过滤多维数组A.A可以是逻辑的,或者可以是任何类和维的非稀疏数值数组。结果B的大小和类别与A相同。

N-D filtering of multidimensional images. B = imfilter(A,H) filters the multidimensional array A with the multidimensional filter H. A can be logical or it can be a nonsparse numeric array of any class and dimension. The result, B, has the same size and class as A.

SO Imfilter

区域最大值。 BW = imregionalmax(I)计算I的区域最大值.imregionalmax返回识别I中的区域最大值的位置的二进制图像BW,其大小与I相同。在BW中,设置为1的像素识别区域最大值;所有其他像素都设置为0。

Regional maxima. BW = imregionalmax(I) computes the regional maxima of I. imregionalmax returns a binary image, BW, the same size as I, that identifies the locations of the regional maxima in I. In BW, pixels that are set to 1 identify regional maxima; all other pixels are set to 0.

SO Imregionalmax

2-D阶统计滤波。 B = ordfilt2(A,ORDER,DOMAIN)将A中的每个元素替换为由DOMAIN中非零元素指定的邻近排序集合中的ORDER-th元素。

2-D order-statistic filtering. B=ordfilt2(A,ORDER,DOMAIN) replaces each element in A by the ORDER-th element in the sorted set of neighbors specified by the nonzero elements in DOMAIN.

SO Ordfilt2

选择多边形感兴趣区域。使用roipoly选择图像中的多边形感兴趣区域。 roipoly返回一个二进制映像,您可以用它作为掩码过滤的掩码。

Select polygonal region of interest. Use roipoly to select a polygonal region of interest within an image. roipoly returns a binary image that you can use as a mask for masked filtering.

SO Roipoly

。 [FX,FY] =梯度(F)返回矩阵F的数字梯度.FX对应于dF / dx,x(水平)方向上的差异。 FY对应于dF / dy,y(垂直)方向上的差异。假定每个方向上的点之间的间隔为1。当F是向量时,DF =渐变(F)是1-D渐变。

Approximate gradient. [FX,FY] = gradient(F) returns the numerical gradient of the matrix F. FX corresponds to dF/dx, the differences in x (horizontal) direction. FY corresponds to dF/dy, the differences in y (vertical) direction. The spacing between points in each direction is assumed to be one. When F is a vector, DF = gradient(F)is the 1-D gradient.

SO渐变

索引从多个下标。 sub2ind用于确定与给定的一组下标值对应的等效单个索引。

Linear index from multiple subscripts. sub2ind is used to determine the equivalent single index corresponding to a given set of subscript values.

SO sub2ind

求解线性方程组 A * x = B 。矩阵A和B必须具有相同的行数。

solves the system of linear equations A*x = B. The matrices A and B must have the same number of rows.

cv :: solve

这篇关于Matlab到OpenCV转换的示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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