⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 matrixdata.h

📁 图像处理的压缩算法
💻 H
📖 第 1 页 / 共 5 页
字号:
			for(ii = 0; ii < mShifted.GetNumRows(); ii++)
			{
				for(jj = 0; jj < mShifted.GetNumCols(); jj++)
					printf("%g\t",mShifted[ii][jj]);
				printf("\n");
			}

			mSource.FFTShift(mShifted, 2);
			printf("After shifting relative to second dimension:\n");
			for(ii = 0; ii < mShifted.GetNumRows(); ii++)
			{
				for(jj = 0; jj < mShifted.GetNumCols(); jj++)
					printf("%g\t",mShifted[ii][jj]);
				printf("\n");
			}
		Parameter:
			mbShifted=The output matrix in which the shifted matrix is returned 
			nDim=Shifts can occur row wise (relative to the first dimension when nDim=1), column wise (relative
				to the second dimension when nDim=2), or relative to both or the first dimension and then the second
				dimension (when nDim=-1 default)	 
		Return:
			Returns 0 on success and a non-zero error code on failure:
				-1=nDim is not -1, 1, or 2
				-2=Internal casting error
		SeeAlso:
			matrixbase::IFFTShift
	*/
	int		FFTShift(matrixbase & mbShifted,  int nDim = -1); // Shift this matrix placing the result in the matrix passed as an argument.

	/**
			Inverse FFTShift. Inverse FFTShifts can occur row wise or relative to the
			first dimension (nDim=1), column wise or relative to the second dimension
			(nDim=2), or relative to both or the first dimension and then the second
			dimension (nDim=-1 default). The result matrix and this matrix can be the
			same (i.e m1.IFFTShift(m1);).
		Example:
			matrix mSource = {{1,2,3},{4,5,6},{7,8,9}};
			matrix mShifted;
			int ii, jj;
			printf("Before shifting:\n");
			for(ii = 0; ii < mSource.GetNumRows(); ii++)
			{
				for(jj = 0; jj < mSource.GetNumCols(); jj++)
					printf("%g\t",mSource[ii][jj]);
				printf("\n");
			}

			mSource.FFTShift(mShifted);
			printf("After shifting for FFT:\n");
			for(ii = 0; ii < mShifted.GetNumRows(); ii++)
			{
				for(jj = 0; jj < mShifted.GetNumCols(); jj++)
					printf("%g\t",mShifted[ii][jj]);
				printf("\n");
			}

			mShifted.IFFTShift(mShifted);
			printf("After un-shifting (IFFTShift) for FFT:\n");
			for(ii = 0; ii < mShifted.GetNumRows(); ii++)
			{
				for(jj = 0; jj < mShifted.GetNumCols(); jj++)
					printf("%g\t",mShifted[ii][jj]);
				printf("\n");
			}
		Parameter:
			mbShifted=The output matrix in which the un-shifted matrix is returned 
			nDim=Inverse FFTShifts can occur row wise (relative to the first dimension when nDim=1), column wise (relative
				to the second dimension when nDim=2), or relative to both or the first dimension and then the second
				dimension (when nDim=-1 default)	 
		Return:
			Returns 0 on success and a non-zero error code on failure:
				-1=nDim is not -1, 1, or 2
				-2=Internal casting error
		SeeAlso:
			matrixbase::FFTShift
	*/
	int		IFFTShift(matrixbase & mbShifted,  int nDim = -1); // Inverse FFTShift.

	/**
			Round each cell of this matrix to the nearest integer less than
			the current cell value (toward minus infinity).			.
		Example:
			int ii, jj,	nRows, nCols;
			matrix mResult;
			matrix mSource = {{1.001,2.009,-3.99999,4.0005,-5.999},
			                  {-6.2000,7.345,8.9999,-9.0001,10.0001}};

			printf("The source data:\n");
			nCols = mSource.GetNumCols();
			nRows = mSource.GetNumRows();
			for( ii = 0; ii < nRows; ii++)
			{
				for(jj = 0; jj < nCols; jj++)
				printf("%g\t",mSource[ii][jj]);
				printf("\n");
			}

			mSource.Floor(mResult);

			printf("After Floor function:\n");
			for( ii = 0; ii < nRows; ii++)
			{
				for(jj = 0; jj < nCols; jj++)
				printf("%g\t",mResult[ii][jj]);
				printf("\n");
			}
		Parameters:
			mbFloor=Output matrix containing the results
		Return:
			Returns 0 on success and a non-zero error code on failure. 
		SeeAlso:
			matrixbase::Fix, matrixbase::Round, matrixbase::Ceil
	*/
	int		Floor(matrixbase & mbFloor); // Round each cell of this matrix to the nearest integer less than the current cell value (toward minus infinity).

	/**
			Round each cell of this matrix to the nearest integer (toward zero).			.
		Example:
			int ii, jj,	nRows, nCols;
			matrix mResult;
			matrix mSource = {{1.001,2.009,-3.99999,4.0005,-5.999},
			                  {-6.2000,7.345,8.9999,-9.0001,10.0001}};

			printf("The source data:\n");
			nCols = mSource.GetNumCols();
			nRows = mSource.GetNumRows();
			for( ii = 0; ii < nRows; ii++)
			{
				for(jj = 0; jj < nCols; jj++)
					printf("%g\t",mSource[ii][jj]);
				printf("\n");
			}

			mSource.Fix(mResult);

			printf("After Fix function:\n");
			for( ii = 0; ii < nRows; ii++)
			{
				for(jj = 0; jj < nCols; jj++)
					printf("%g\t",mResult[ii][jj]);
				printf("\n");
			}
		Parameters:
			mbFix=Output matrix containing the results
		Return:
			Returns 0 on success and a non-zero error code on failure. 
		SeeAlso:
			matrixbase::Floor, matrixbase::Round, matrixbase::Ceil
	*/
	int		Fix(matrixbase & mbFix); // Round each cell of this matrix to the nearest integer (toward zero).

	/**
			Round each cell of this matrix to the nearest integer (absolute nearest).			.
		Example:
			int ii, jj,	nRows, nCols;
			matrix mResult;
			matrix mSource = {{1.001,2.009,-3.99999,4.0005,-5.999},
			                  {-6.2000,7.345,8.9999,-9.0001,10.0001}};

			printf("The source data:\n");
			nCols = mSource.GetNumCols();
			nRows = mSource.GetNumRows();
			for( ii = 0; ii < nRows; ii++)
			{
				for(jj = 0; jj < nCols; jj++)
					printf("%g\t",mSource[ii][jj]);
				printf("\n");
			}

			mSource.Round(mResult);

			printf("After Round function:\n");
			for( ii = 0; ii < nRows; ii++)
			{
				for(jj = 0; jj < nCols; jj++)
					printf("%g\t",mResult[ii][jj]);
				printf("\n");
			}
		Parameters:
			mbRound=Output matrix containing the results
		Return:
			Returns 0 on success and a non-zero error code on failure. 
		SeeAlso:
			matrixbase::Floor, matrixbase::Fix, matrixbase::Ceil
	*/
	int		Round(matrixbase & mbRound); // und each cell of this matrix to the nearest integer (absolute nearest).
	
	/**
			Round each cell of this matrix to the nearest integer greater than the
			current cell value (toward positive infinity).			.
		Example:
			int ii, jj,	nRows, nCols;
			matrix mResult;
			matrix mSource = {{1.001,2.009,-3.99999,4.0005,-5.999},
			                  {-6.2000,7.345,8.9999,-9.0001,10.0001}};

			printf("The source data:\n");
			nCols = mSource.GetNumCols();
			nRows = mSource.GetNumRows();
			for( ii = 0; ii < nRows; ii++)
			{
				for(jj = 0; jj < nCols; jj++)
					printf("%g\t",mSource[ii][jj]);
				printf("\n");
			}

			mSource.Ceil(mResult);

			printf("After Ceil function:\n");
			for( ii = 0; ii < nRows; ii++)
			{
				for(jj = 0; jj < nCols; jj++)
					printf("%g\t",mResult[ii][jj]);
				printf("\n");
			}
		Parameters:
			mbCeil=Output matrix containing the results
		Return:
			Returns 0 on success and a non-zero error code on failure. 
		SeeAlso:
			matrixbase::Floor, matrixbase::Fix, matrixbase::Round
	*/
	int		Ceil(matrixbase & mbCeil); // Round each cell of this matrix to the nearest integer greater than the current cell value (toward positive infinity).

	/**
			Make this matrix an N x N identity matrix or an M x N rectangular matrix
			with 1's on the diagonal and zeros elsewhere.
		Example:
			int ii, jj,	nRows, nCols;
			matrix mIdentity;
		
			mIdentity.MakeIdentity(4);
			nCols = mIdentity.GetNumCols();
			nRows = mIdentity.GetNumRows();
			for( ii = 0; ii < nRows; ii++)
			{
				for(jj = 0; jj < nCols; jj++)
					printf("%g\t",mIdentity[ii][jj]);
				printf("\n");
			}
		Parameter:
			mNumRows=Number of rows in the result matrix
			nNumCols=Number of columns of the result matrix (default -1 means mNumRows = nNumCols)
		Return:
			Returns 0 on success or an error code on failure:
				-1=nNumCols and mNumRows are not positive integers (nNumCols can be -1)
		SeeAlso:
			matrixbase::GetLowerTriangular, matrixbase::GetUpperTriangular
	*/
	int		MakeIdentity(int mNumRows, int nNumCols = -1);

	/**
			Copy this matrix and cast the underlying base type to double. 
		Example:
			int ii, jj;
			matrix<int> mInts = {{1,2,3},{4,5,6},{7,8,9}};
			mInts *= 1.1;
						
			printf("Intergers:\n");
			for(ii = 0; ii < mInts.GetNumRows(); ii++)
			{
				for(jj = 0; jj < mInts.GetNumCols(); jj++)
					printf("%d\t",mInts[ii][jj]);
				printf("\n");
			}

			matrix<double> mDoubles;
			mInts.CastToDouble(mDoubles);
			mDoubles *= 1.1;
			
			printf("Doubles:\n");
			for(ii = 0; ii < mDoubles.GetNumRows(); ii++)
			{
				for(jj = 0; jj < mDoubles.GetNumCols(); jj++)
					printf("%g\t",mDoubles[ii][jj]);
				printf("\n");
			}
		Parameters:
			mDouble=The result matrix having an underlying base type of double
		Return:
			Returns 0 on success and a non-zero error code on failure.
		SeeAlso:
			matrixbase::MakeComplex, matrixbase:CastToInteger
	*/
	int		CastToDouble(matrix & mDouble); // Copy this matrix casting the underlying base type to double.

	/**
			Round this matrix placing the results in a matrix having an underlying
			base type of int. The input matrix must have an underlying base type of
			float or double or a run time error is generated. 
		Example:
			int ii, jj;
			
			matrix<double> mDoubles = {{1.1,2.2,3.3},{4.4,5.5,6.6},{7.7,8.8,9.9}};
			printf("Doubles:\n");
			for(ii = 0; ii < mDoubles.GetNumRows(); ii++)
			{
				for(jj = 0; jj < mDoubles.GetNumCols(); jj++)
					printf("%g\t",mDoubles[ii][jj]);
				printf("\n");
			}
			
			matrix<int> mInts; 
			mDoubles.CastToInteger(mInts);
						
			printf("Intergers:\n");
			for(ii = 0; ii < mInts.GetNumRows(); ii++)
			{
				for(jj = 0; jj < mInts.GetNumCols(); jj++)
					printf("%d\t",mInts[ii][jj]);
				printf("\n");
			}
		Parameters:
			mInteger=The result matrix having an underlying base type of int
		Return:
			Returns 0 on success and a non-zero error code on failure.
		SeeAlso:
			matrixbase::MakeComplex, matrixbase::CastToDouble
	*/
	int		CastToInteger(matrix<int> & mInteger); // Round this matrix placing the results in a matrix having an underlying base type of int.

	/**
			Get a lower triangular matrix from this matrix. This matrix and the
			result matrix may be the same.
		Example:
			int ii, jj;

			matrix mSource = {{1,2,3},{4,5,6},{7,8,9}};
			printf("Source:\n");
			for(ii = 0; ii < mSource.GetNumRows(); ii++)
			{
				for(jj = 0; jj < mSource.GetNumCols(); jj++)
					printf("%g\t",mSource[ii][jj]);
				printf("\n");
			}
			
			matrix mResult; 
			mSource.GetLowerTriangular(mResult);
						
			printf("Lower Triangular:\n");
			for(ii = 0; ii < mResult.GetNumRows(); ii++)
			{
				for(jj = 0; jj < mResult.GetNumCols(); jj++)
					printf("%g\t",mResult[ii][jj]);
				printf("\n");
			}
		Parameters:
			mbResult=The result matrix containing only the lower part 
			nNumDiagonal=Default 0 is the main diagonal, > 0 is above the
				main diagonal, and < 0 is below the main diagonal.
		Return:
			Returns 0 on success and a non-zero error code on failure.
		   		-1=Internal cast error.
		SeeAlso:
			matrixbase::GetUpperTriangular, matrixbase::MakeIdentity, matrixbase::SetDiagonal, matrixbase::GetDiagonal
	*/
	int		GetLowerTriangular(matrixbase & mbResult, int nNumDiagonal = 0); // Get a lower triangular matrix from this matrix.

	/**
			Get an upper triangular matrix from this matrix. This matrix and 
			the result matrix may be the same.
		Example:
			int ii, jj;

			matrix mSource = {{1,2,3},{4,5,6},{7,8,9}};
			printf("Source:\n");
			for(ii = 0; ii < mSource.GetNumRows(); ii++)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -