#ifndef AURORA_FUNCTION2D_H #define AURORA_FUNCTION2D_H #include #include #include "Matrix.h" #include "Function1D.h" namespace Aurora { enum FunctionDirection { Column, Row, All }; float immse(const Matrix &aImageA, const Matrix &aImageB); Matrix inv(const Matrix &aMatrix); Matrix inv(Matrix &&aMatrix); Matrix interp2(const Matrix &aX, const Matrix &aY, const Matrix &aV, const Matrix &aX1, const Matrix &aY1, InterpnMethod aMethod); Matrix interpn(const Matrix &aX, const Matrix &aY, const Matrix &aV, const Matrix &aX1, const Matrix &aY1, InterpnMethod aMethod); Matrix std(const Matrix &aMatrix); /** * 求矩阵最小值,可按行、列、单元, 目前不支持三维,不支持复数 * @param aMatrix 目标矩阵 * @param direction 方向,Column, Row, All * @return */ Matrix min(const Matrix &aMatrix, FunctionDirection direction = Column); Matrix min(const Matrix &aMatrix, FunctionDirection direction, long &rowIdx, long &colIdx); /** * 求矩阵最小值,可按行、列、单元, 目前不支持三维,不支持复数 * @param aMatrix 目标矩阵 * @param direction 方向,Column, Row, All * @return 最大值矩阵 */ Matrix max(const Matrix &aMatrix, FunctionDirection direction = Column); Matrix max(const Matrix &aMatrix, FunctionDirection direction, long &rowIdx, long &colIdx); /** * 比较两个矩阵,求对应位置的最小值,不支持三维 * @attention 矩阵形状不一样时,如A为[MxN],则B应为标量或[1xN]的行向量 * @param aMatrix 目标矩阵1 * @param aOther 目标矩阵2 * @return 最小值矩阵 */ Matrix min(const Matrix &aMatrix, const Matrix &aOther); /** * 比较两个矩阵,求对应位置的最大值,不支持三维 * @attention 矩阵形状不一样时,如A为[MxN],则B应为标量或[1xN]的行向量 * @param aMatrix 目标矩阵1 * @param aOther 目标矩阵2 * @return 最大值矩阵 */ Matrix max(const Matrix &aMatrix, const Matrix &aOther); /** * 比较矩阵和产量,求对应位置的最大值 * @attention 矩阵形状不一样时,如A为[MxN],则B应为标量或[1xN]的行向量 * @param aMatrix 目标矩阵1 * @param aOther 目标矩阵2 * @return 最大值矩阵 */ Matrix max(const Matrix &aMatrix, const float aValue); /** * 求矩阵和,可按行、列、单元, 目前不支持三维 * @param aMatrix 目标矩阵 * @param direction 方向,Column, Row, All * @return 求和结果矩阵 */ Matrix sum(const Matrix &aMatrix, FunctionDirection direction = Column); /** * 求矩阵平均值,可按行、列、单元, 目前不支持三维,不支持复数 * @param aMatrix 目标矩阵 * @param direction 方向,Column, Row, All * @param aIncludeNan 是否包含nan * @return 平均值矩阵 */ Matrix mean(const Matrix &aMatrix, FunctionDirection direction = Column, bool aIncludeNan = true); /** * @brief 矩阵排序 按列, 目前不支持三维,不支持复数 * * @param aMatrix 目标矩阵 * @param direction 排序方向。不支持ALL * @return Matrix 排序后矩阵 */ Matrix sort(const Matrix &aMatrix,FunctionDirection direction = Column); /** * @brief 矩阵排序 按列, 目前不支持三维,不支持复数 * * @param aMatrix 目标矩阵 * @param direction 排序方向。不支持ALL * @return Matrix 排序后矩阵 */ Matrix sort(Matrix &&aMatrix,FunctionDirection direction = Column); /** * 基于第一列中的元素按升序对矩阵行进行排序。 * 当第一列包含重复的元素时,sortrows 会根据下一列中的值进行排序,并对后续的相等值重复此行为。 * @attention 目前不支持三维,不支持复数 * @param aMatrix 目标矩阵 * @param indexMatrix 排序后各行的原索引矩阵指针,非必须 * @return 排序后矩阵 */ Matrix sortrows(const Matrix &aMatrix, Matrix* indexMatrix=nullptr); /** * 对矩阵求中间值 按列, 目前不支持三维,不支持复数 * @param aMatrix 目标矩阵 * @return 中值矩阵 */ Matrix median(const Matrix &aMatrix); /** * FFT,支持到2维,输入可以是常数可以是复数,输出必是复数 * @param aMatrix 目标矩阵 * @param aFFTSize 目标矩阵需要处理的长度,默认为-1即全部 * @return fft后的复数矩阵 */ Matrix fft(const Matrix &aMatrix, long aFFTSize = -1); /** * fftshift,在原有数据上进行修改,将fft的数据的前半部分和后半部分交换,支持2D数据 * @param aMatrix */ void fftshift(Matrix &aMatrix); /** * fftshift,在原有数据上进行修改,将fft的数据的前半部分和后半部分交换,支持2D数据 * @param aMatrix */ void ifftshift(Matrix &aMatrix); /** * 逆fft,支持到2维,输入必须是复数,输出必是复数 * @attention 如有需要可使用real去除虚部 * @param aMatrix * @return ifft后的复数矩阵 */ Matrix ifft(const Matrix &aMatrix, long aFFTSize = -1); /** * Symmetric逆fft,支持到2维,输入必须是复数,输出必是实数 * @param aMatrix * @return ifft后的实数矩阵 */ Matrix ifft_symmetric(const Matrix &aMatrix,long length); /** * hilbert,支持到2维,输入必须是复数,输出必是复数 * @param aMatrix * @return */ Matrix hilbert(const Matrix &aMatrix); /** * prod,支持到2维 * @param aMatrix * @return */ Matrix prod(const Matrix &aMatrix); Matrix dot(const Matrix &aMatrix, const Matrix &aOther, FunctionDirection direction = Column); /** * 转换下标为索引值 * @attention 索引值按照其实为1与matlab对应,在C++中使用需要-1 * @param aVMatrixSize * @param aSliceIdxs * @return */ Matrix sub2ind(const Matrix &aVMatrixSize, std::initializer_list aSliceIdxs); }; #endif // AURORA_FUNCTION2D_H