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

📄 ocn_c06.h

📁 图像处理的压缩算法
💻 H
📖 第 1 页 / 共 5 页
字号:
		for (i = 0; i<n; ++i)
		{
			printf("%10.4f", v[j*n + i]);
		 	if(i % 6 == 5 && i != n-1 )
		 		printf("\n " );
		}
		printf("\n\n");
	}
}	
	
	The output is following:
	
	m = 3 n = 6
	
	Original data values
	
			0.3854 	  0.6772 	0.1138    0.6751 	0.6362    0.1424
			0.5417    0.2983 	0.1181    0.7255 	0.8638    0.8723
			0.9172    0.0644 	0.6037    0.6430 	0.0428    0.4815
			
	Discrete Fourier transforms in Hermitian format
	
			1.0737 	 -0.1041  	0.1126   -0.1467   -0.3738 	 -0.0044
			1.3961   -0.0365 	0.0780   -0.1521   -0.0607 	  0.4666
			1.1237    0.0914 	0.3936 	  0.1530 	0.3458   -0.0508
			
	Fourier transforms in full complex form
	
	Real 	1.0737   -0.1041 	0.1126 	 -0.1467 	0.1126   -0.1041
	Imag 	0.0000   -0.0044   -0.3738    0.0000 	0.3738    0.0044
	
	Real 	1.3961   -0.0365 	0.0780 	 -0.1521 	0.0780   -0.0365
	Imag 	0.0000    0.4666   -0.0607    0.0000 	0.0607   -0.4666
	
	Real 	1.1237    0.0914 	0.3936    0.1530 	0.3936    0.0914
	Imag 	0.0000   -0.0508 	0.3458    0.0000   -0.3458    0.0508
		

Return:
	The function returns NAG error code or 0 if no error.

	11: On entry, n must not be less than 1: n = _value_.
		
	successfully call of the nag_fft_init_trig function.
*/

	int nag_fft_init_trig(
		int n,	//the value  in the Fourier transform function being called.
		double trig[]	//the trigonometric coefficients.
  ); // calculates the trigonometric coefficients required for the computation of discrete Fourier transforms.


/**	c06hac
		computes the discrete Fourier sine transforms of m sequences of n real data values.

Example1:
	Assume "Data1" Worksheet has 2 columns, the first column contains 18 data.  This piece of 
	code computes the discrete Fourier sine transforms of 3 sequences of 6 real data values.
	The result was put to the second column.	
	
	double trig[40];
	int m = 3, n = 6;
	//Attach 2 Datasets to these 2 columns
	Dataset xx("data1",0);
	Dataset dx("data1",1);
	x = xx;
	nag_fft_init_trig(n, trig); 
	nag_fft_multiple_sine(m, n, x, trig); 
	//Put the result to the second column.
	dx = x;	
	
		
Example2:
	This program reads in sequences of real data values and prints their Fourier sine 
	transforms (as computed by nag_fft_multiple_sine). It then calls nag_fft_multiple_sine
	again and prints the results which may be compared with the original sequence.

void test_nag_fft_multiple_sine()
{
	
	double trig[40];
	int i, j, m, n, row_len;
	double x[100] = {0.6772, 0.1138, 0.6751, 0.6362, 0.1424,
					 0.2983, 0.1181, 0.7255, 0.8638, 0.8723,
					 0.0644, 0.6037, 0.6430, 0.0428, 0.4815};
	m = 3;
	n = 6;	
	row_len = n - 1;
	
	printf("\nOriginal data values\n\n");
	for (i = 0; i<m; ++i)
	{
		printf(" ");
		for (j = 0; j<row_len; ++j)
		{
			printf("%10.4f", x[(i)*row_len + (j)]);
		 	if((j % 7 )== 6 && (j != row_len-1 ))
		 		printf("\n " );
		}
		printf("\n");
	}
	
	nag_fft_init_trig(n, trig); 
	nag_fft_multiple_sine(m, n, x, trig); 
	printf("\nDiscrete Fourier sine transforms\n\n");
	for (i = 0; i<m; ++i)
	{
		printf(" ");
		for (j = 0; j<row_len; ++j)
		{
			printf("%10.4f", x[(i)*row_len + (j)]);
		 	if((j % 7 )== 6 && (j != row_len-1 ))
		 		printf("\n " );
		}
		printf("\n");
	}
	
	nag_fft_multiple_sine(m, n, x, trig);
	printf("\nOriginal data as restored by inverse transform\n\n");
	for (i = 0; i<m; ++i)
	{
		printf(" ");
		for (j = 0; j<row_len; ++j)
		{
			printf("%10.4f", x[(i)*row_len + (j)]);
		 	if((j % 7 )== 6 && (j != row_len-1 ))
		 		printf("\n " );
		}
		printf("\n");
	}
}	

	
	The output is following:
	
	Original data values
	
	0.6772    0.1138 	0.6751    0.6362 	0.1424
	0.2983    0.1181 	0.7255    0.8638 	0.8723
	0.0644    0.6037 	0.6430    0.0428 	0.4815
	
	Discrete Fourier sine transforms
	
	1.0014    0.0062 	0.0834    0.5286 	0.2514
	1.2477   -0.6599 	0.2570    0.0858 	0.2658
	0.8521    0.0719   -0.0561   -0.4890 	0.2056
	
	Original data as restored by inverse transform
	
	0.6772    0.1138 	0.6751    0.6362 	0.1424
	0.2983    0.1181 	0.7255    0.8638 	0.8723
	0.0644    0.6037 	0.6430    0.0428 	0.4815
		
Return:
	The function returns NAG error code or 0 if no error.
	
	11:  On entry, m must not be less than 1: m = _value_.  On entry, n must not be less than 1: n = _value_.
	139: Value of n and trig array are incompatible or trig array is not initialized.
	73:  Memory allocation failed.
		
	successfully call of the nag_fft_multiple_sine function.	
*/

	int	nag_fft_multiple_sine(
		int m, // the number of sequences to be transformed.
		int n, // one more than the number of real values in each sequence, i.e. the number of values in each sequence is n - 1.
		double x[],	// Input: the m data sequences stored in x consecutively.  Output: the m Fourier sine transforms stored consecutively, overwrite the corresponding original sequence.
		const double trig[]	//the trigonometric coefficients are returned by a call of nag fft init trig (c06gzc).
  ); // computes the discrete Fourier sine transforms of m sequences of real data values.


/**	c06hbc
		computes the discrete Fourier cosine transforms of m sequences of n real data values.

Example1:
	Assume "Data1" Worksheet has 2 columns, the first column contains 18 data.  This piece of 
	code computes the discrete Fourier cosine transforms of 3 sequences of 6 real data values.
	The result was put to the second column.	
	
	double trig[40];
	int m = 3, n = 6;
	//Attach 2 Datasets to these 2 columns
	Dataset xx("data1",0);
	Dataset dx("data1",1);
	x = xx;
	nag_fft_init_trig(n, trig); 
	nag_fft_multiple_cosine(m, n, x, trig); 
	//Put the result to the second column.
	dx = x;	
	
			
Example2:
	This program reads in sequences of real data values and prints their Fourier cosine 
	transforms (as computed by nag_fft_multiple_cosine). It then calls nag_fft_multiple_cosine 
	again and prints the results which may be compared with the original sequence.
	
void test_nag_fft_multiple_cosine()
{	
	double trig[40];
	int i, j, m, n, row_len;
    double x[105] = {0.3854, 0.6772, 0.1138, 0.6751, 0.6362, 0.1424,0.9562,
					 0.5417, 0.2983, 0.1181, 0.7255, 0.8638, 0.8723,0.4936,
					 0.9172, 0.0644, 0.6037, 0.6430, 0.0428, 0.4815,0.2057};     
	m = 3;
	n = 6;
	row_len = n + 1;
	
	printf("\nOriginal data values\n\n");
	for (i = 0; i<m; ++i)
	{
		printf(" ");
		for (j = 0; j<row_len; ++j)
		{
			printf("%10.4f", x[(i)*row_len + (j)]);
		 	if((j % 7 )== 6 && (j != row_len-1 ))
		 		printf("\n " );
		 }
		printf("\n");
	}
	

	nag_fft_init_trig(n, trig); 
	nag_fft_multiple_cosine(m, n, x, trig); 
	printf("\nDiscrete Fourier cosine transforms\n\n");
	for (i = 0; i<m; ++i)
	{
		printf(" ");
		for (j = 0; j<row_len; ++j)
		{
			printf("%10.4f", x[(i)*row_len + (j)]);
		 	if((j % 7 )== 6 && (j != row_len-1 ))
		 		printf("\n " );
		}
		printf("\n");
	}
	
	nag_fft_multiple_cosine(m, n, x, trig); 
	printf("\nOriginal data as restored by inverse transform\n\n");
	for (i = 0; i<m; ++i)
	{
		printf(" ");
		for (j = 0; j<row_len; ++j)
		{
			printf("%10.4f", x[(i)*row_len + (j)]);
		 	if((j % 7 )== 6 && (j != row_len-1 ))
		 		printf("\n " );
		}
		printf("\n");
	}
}

	The output is following:
	
	Original data values
	
	0.3854    0.6772 	0.1138    0.6751 	0.6362    0.1424 	0.9562
	0.5417    0.2983 	0.1181    0.7255 	0.8638    0.8723 	0.4936
	0.9172    0.0644 	0.6037    0.6430 	0.0428    0.4815 	0.2057
	
	Discrete Fourier cosine transforms
	
	1.6833   -0.0482 	0.0176    0.1368 	0.3240   -0.5830   -0.0427
	1.9605   -0.4884   -0.0655    0.4444 	0.0964    0.0856   -0.2289
	1.3838    0.1588   -0.0761 	 -0.1184 	0.3512    0.5759  	0.0110
	
	Original data as restored by inverse transform
	
	0.3854    0.6772 	0.1138    0.6751 	0.6362    0.1424 	0.9562
	0.5417    0.2983 	0.1181    0.7255 	0.8638    0.8723 	0.4936
	0.9172    0.0644 	0.6037    0.6430 	0.0428    0.4815 	0.2057
	
Return:
	The function returns NAG error code or 0 if no error.
	
	11:  On entry, m must not be less than 1: m = _value_.  On entry, n must not be less than 1: n = _value_.
	139: Value of n and trig array are incompatible or trig array is not initialized.
	73:  Memory allocation failed.
	
	successfully call of the nag_fft_multiple_cosine function.	
*/

	int nag_fft_multiple_cosine(
		int m, // the number of sequences to be transformed.
		int n, // one less than the number of real values in each sequence, i.e., the number of values in each sequence is n + 1.
		double x[], // Input:the m data sequences stored in x.  Output:the m Fourier cosine transforms stored consecutively, overwrite the corresponding original sequence.
		const double trig[]	//the trigonometric coefficients as returned by a call of nag_fft_init_trig (c06gzc).
  ); // computes the discrete Fourier cosine transforms of m sequences of real data values.


/**	c06hcc
		computes the discrete quarter-wave Fourier sine transforms of m sequences of real data values.

Example1:
	Assume "Data1" Worksheet has 2 columns, the first column contains 18 data.  This piece of 
	code computes the discrete quarter-wave Fourier sine transforms of 3 sequences of 6 real data values.
	The result was put to the second column.	
	
	double trig[40];
	int m = 3, n = 6;
	//Attach 2 Datasets to these 2 columns
	Dataset xx("data1",0);
	Dataset dx("data1",1);
	x = xx;
	nag_fft_init_trig(n, trig);	
	nag_fft_multiple_qtr_sine(Nag_ForwardTransform, m, n, x, trig);
	//Put the result to the second column.
	dx = x;	
	
			
Example2:
	This program reads in sequences of real data values and prints their quarter-wave sine 
	transforms as computed by nag_fft_multiple_qtr_sine with direct = Nag_ForwardTransform. 
	It then calls nag_fft_multiple_qtr_sine again with direct = Nag BackwardTransform 
	and prints the results which may be compared with the original data.

void test_nag_fft_multiple_qtr_sine()
{	
	double trig[40];
	int i, j, m, n;
	double x[100] = {0.3854, 0.6772, 0.1138, 0.6751, 0.6362, 0.1424,
					 0.5417, 0.2983, 0.1181, 0.7255, 0.8638, 0.8723,
					 0.9172, 0.0644, 0.6037, 0.6430, 0.0428, 0.4815};
	m = 3;
	n = 6;
	
	printf("\nOriginal data values\n\n");
	for (j = 0; j<m; ++j)
	{
		printf(" ");
		for (i = 0; i<n; ++i)
		{
			printf("%10.4f", x[j*n + i]);
		 	if((i % 7 )== 6 && (i != n-1 ))
		 		printf("\n " );
		}
		printf("\n");
	}
	nag_fft_init_trig(n, trig);
	
	nag_fft_multiple_qtr_sine(Nag_ForwardTransform, m, n, x, trig);
	printf("\nDiscrete quarter-wave Fourier sine transforms\n\n");
	
	for (j = 0; j<m; ++j)
	{
		printf(" ");
		for (i = 0; i<n; ++i)
		{
			printf("%10.4f", x[j*n + i]);
		 	if((i % 7 )== 6 && (i != n-1 ))
		 		printf("\n " );
		}
		printf("\n");
	}

	nag_fft_multiple_qtr_sine(Nag_BackwardTransform, m, n, x, trig);
	printf("\nOriginal data as restored by inverse transform\n\n");
	for (j = 0; j<m; ++j)
	{
		printf(" ");
		for (i = 0; i<n; ++i)
		{
			printf("%10.4f", x[j*n + i]);
		 	if((i % 7 )== 6 && (i != n-1 ))
		 		printf("\n " );
		}
		printf("\n");
	}
}

	The output is the following:
	
	Original data values
	
	0.3854    0.6772 	0.1138    0.6751 	0.6362 	  0.1424
	0.5417    0.2983 	0.1181    0.7255 	0.8638    0.8723
	0.9172    0.0644 	0.6037    0.6430 	0.0428    0.4815
	
	Discrete quarter-wave Fourier sine transforms
	
	0.7304    0.2078 	0.1150    0.2577   -0.2869 	 -0.0815
	0.9274   -0.1152 	0.2532    0.2883   -0.0026   -0.0635
	0.6268    0.3547 	0.0760    0.3078 	0.4987   -0.0507
	
	Original data as restored by inverse transform
	
	0.3854    0.6772 	0.1138    0.6751 	0.6362    0.1424
	0.5417    0.2983 	0.1181    0.7255 	0.8638    0.8723
	0.9172    0.0644 	0.6037    0.6430 	0.0428    0.4815

Return:
	The function returns NAG error code or 0 if no error.
	
	11:  On entry, m must not be less than 1: m = _value_.  On entry, n must not be less than 1: n = _value_.
	139: Value of n and trig array are incompatible or trig array is not initialized.
	70:  On entry, parameter direct has an illegal value.

	successfully call of the nag_fft_multiple_qtr_sine function.
*/

	int nag_fft_multiple_qtr_sine(
		Nag_TransformDirection direct, //determine which direction transform to be computed.
		int m,	// the number of sequences to be transformed.
		int n,	// the number of real values in each sequence,  
		double x[],	// Input:the m data sequences stored in x consecutively.  Output:the m quarter-wave sine transforms stored consecutively.
		const double trig[]	//the trigonometric coefficients as returned by a call of nag_fft_init_trig (c06gzc).
  );  // computes the discrete quarter-wave Fourier sine transforms of m sequences of real data values.


/**	c06hdc
		computes the discrete quarter-wave Fourier cosine transforms of m sequences of real data values.

Example1:
	Assume "Data1" Worksheet has 2 columns, the first column contains 18 data.  This piece of 
	code computes the discrete quarter-wave Fourier cosine transforms of 3 sequences of 6 real data values.
	The result was put to the second column.	
	
	double trig[40];
	int m = 3, n = 6;
	//Attach 2 Datasets to 

⌨️ 快捷键说明

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