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

📄 analysis_utils.h

📁 图像处理的压缩算法
💻 H
📖 第 1 页 / 共 2 页
字号:
/*------------------------------------------------------------------------------*
 * File Name:Analysis_utils.h 													*
 * Creation: CPY 3/11/03														*
 * Purpose: Origin's basic internal analysis routines							*
 * Copyright (c) Originlab Corp.	2003										*
 * All Rights Reserved															*
 * 																				*
 * Modification Log:															*
 *------------------------------------------------------------------------------*/

 
#ifndef _ANALYSIS_UTILS_H
#define _ANALYSIS_UTILS_H

/** >Analysis
		Converts regular XYZ data to a matrix.
		If asked for, data is examined for deviations.
	Example:
		//This example fill a matrix with values in Data1.
		//For this samples to work, Data1 must exist in the project contains 3 column A, B, C
		void run_convert_regular_xyz_to_matrix()
		{
			Dataset dsX("Data1_A"), dsY("Data1_B"), dsZ("Data1_C");
			vector vecX(dsX), vecY(dsY), vecZ(dsZ);
			
			MatrixLayer ml;						//Create a new Matrix to get the result
			ml.Create();
			Matrix matData(ml);
			
			double dXmax, dXmin;
			vecX.GetMinMax(dXmin, dXmax);		//Get the maximum and minimum values of X
			
			double dYmax, dYmin;
			vecY.GetMinMax(dYmin, dYmax);		//Get the maximum and minimum values of Y
		
			convert_regular_xyz_to_matrix(vecX, vecY, vecZ, matData, dXmin, dXmax, dYmin, dYmax); 	
		}
	Parameters:
		vecX,Y,Z:		Input: regular XYZ data
		dXmin, dXmax:	min, max of x data - can use for setting coordinates of Matrix object
		dYmin, dYmax:	min, max of y data - can use for setting coordinates of Matrix object
		bCheckData:		true: check data for irregularities; false: do no checking 
						If user knows data is perfectly regular, can set to false for faster operation
	Return:
		0:			success
		1:			XYZ vectors are of unequalsize, or result matrix smaller than 2x2
		2:			could not find steps in data
		3:			groups in x/y do not match group length in y/x
		4:			too much deviation in x/y data
*/
int convert_regular_xyz_to_matrix(vector& vecX, vector& vecY, vector& vecZ, matrix& matData, double& dXmin,
									double& dXmax, double& dYmin, double& dYmax, bool bCheckData = true);

/** >Analysis
		Performs gridding of random XYZ data.
		The gridding is performed by calling NAG functions.
		Two gridding methods, Renka-Cline and Modified Shepard's method are available.
		For more details on these methods, see documentation for NAG function e01_sac.
	Example:
		int iRet = random_gridding_nag(vecX, vecY, vecZ)	// Renka-Cline method
		int random_gridding_nag(vecX, vecY, vecZ, 1)		// Shepard's method
	Parameters:
		vecX,Y,Z:		Input: random XYZ data
		matResult:		matrix with gridded data
		dXmin, dXmax:	min, max of x data - can use for setting coordinates of Matrix object
		dYmin, dYmax:	min, max of y data - can use for setting coordinates of Matrix object
		iMethod:		0: Renka-Cline gridding; <>0: Modified Shepard's method
		dQIL:			Quadratic Interpolant Locality - used only by Shepard's method
		dWFL:			Weight Function Locality - used only by Shepard's method
	Return:
		0:		success
		-1:		Error in creating matrix
		NAG 	error codes:
		70: 	Parameter method had an illegal value.
		11: 	The number of points is less than 3.
		73: 	Memory allocation failed.
		245: 	All the (x,y) pairs are collinear.
		246: 	Data pair is not unique. Duplicate points are found in the (x,y) pair.
		247: 	Invalid dQIL and dWFL for Shepard's method.
		249: 	(Warning)The minimum number of data points that lie within the radius of 
				any node is smaller that the interpolant may be unsatisfactory in regions 
				where the data points are sparse.
		251: 	(Warning)The evaluation point lies outside the triangulation boundary.  
				The returned value was computed by extrapolation.
		252: 	On entry,the interpolant cannot be evaluted because the evaluation 
				point is outside the support region of the input data points.
	See Also:
		convert_regular_xyz_to_matrix
*/
int convert_random_xyz_to_matrix_nag(vector& vecX, vector& vecY, vector& vecZ, 
			matrix& matResult, double& dXmin, double& dXmax, double& dYmin, double& dYmax, 
			int iMethod = 0, double dQIL = 1, double dWFL = 1);

/** >Analysis
		Removes duplicate points from XYZ data.
		Duplicates are replaced with mean Z value.
	Example:
		//This example removes the duplicated values in Data1.
		//For this samples to run, Data1 should exist in the project with A, B, C columns.
		void run_xyz_remove_duplicates()
		{
			Dataset dsX("Data1_A"), dsY("Data1_B"), dsZ("Data1_C");
			vector vecX(dsX), vecY(dsY), vecZ(dsZ);
			
			xyz_remove_duplicates(vecX, vecY, vecZ);
			
			dsX = vecX;
			dsY = vecY;
			dsZ = vecZ;
		}
	Parameters:
		vecX,Y,Z:		Input: XYZ data; Output: XYZ vectors with duplicates removed
	Return:
		0:			success
		1:			XYZ vectors are of incorrect length
*/
int xyz_remove_duplicates(vector& vecX, vector& vecY, vector& vecZ);

/** >Analysis
		Converts sparse XYZ data to a matrix.
		Sparse data is regular data with some rows missing.
	Example:
		//This example convert Data1_A, Data1_B, Data1_C into a sparse matrix.
		//For this sample to run, Data1 with column A, B, C must exist. 
		void run_convert_sparse_xyz_to_matrix()
		{
			Dataset dsX("Data1_A"), dsY("Data1_B"), dsZ("Data1_C");
			vector vecX(dsX), vecY(dsY), vecZ(dsZ);
			
			MatrixLayer ml;
			ml.Create();				// Create a new matrix to get the result
			Matrix matData(ml);
			
			double dXend, dXbegin;
			double dYend, dYbegin;
			double dXstep; 
			double dYstep; 
			
			convert_sparse_find_min_max_step(vecX, dXbegin, dXend, dXstep); //Find the step
			convert_sparse_find_min_max_step(vecY, dYbegin, dYend, dYstep);	//Find the step
			
			convert_sparse_xyz_to_matrix(vecX, vecY, vecZ, matData, dXbegin, dXend, dXstep, 
						dYbegin, dYend, dYstep);
		}
	Parameters:
		vecX,Y,Z:				Input: regular XYZ data
		matResult:				Output: resulting matrix
		dXmin, dXmax: dXStep:	Input: min, max and stepsize in X. 
							  	Call convert_sparse_find_min_max_step to estimate these values.
		dYmin, dYmax: dYStep: 	Input: min, max and stepsize in Y. 
							  	Call convert_sparse_find_min_max_step to estimate these values.
		iPrecision:				Input: precision used to locate values; same as under Data_list() function
 	Return:
				0:				All points were converted
				-1:				xyz vectors are of different/incorrect size
				-2:				Matrix size too large - could be due to very small step value
				-3:				Error in creating matrix object
				positive:		Number of points that were discarded
		
*/
int convert_sparse_xyz_to_matrix(vector& vecX, vector& vecY, vector& vecZ, matrix& matResult, double dXbegin, double dXend, double dXstep, double dYbegin, double dYend, double dYstep, int iPrecision = 8);

/** >Analysis
		Compute min, max and step value for sparse matrix conversion.
	Example:
		int iRet = convert_sparse_find_min_max_step(vec, dMin, dMax, dStep);
	Parameters:
		vec:				vector with data
		dMin, dMax, dStep:	min, max and step values
	Return:
		0:			success
	See Also:
		convert_sparse_xyz_to_matrix
*/
int convert_sparse_find_min_max_step(vector& vec, double& dMin, double& dMax, double& dStep);

/** >Curve
		Find Worksheet and Column names from a Curve 
	Example:
		//This example get the dataset name of the curve in Graph1.
		//For this sample to work, Graph1 must exist in the project.
		void run_curve_get_wks_col_names()
		{
			GraphLayer gl("Graph1", 0);				//Get the first layer of Graph1
			if(gl)
			{
				DataPlot dp = gl.DataPlots(0);      // Get first data plot in graph layer
				if(dp)                              // If valid DataPlot...
				{
					Curve crv(dp);   				// Get Curve from DataPlot
					string strX, strY, strWks;		
					strWks = curve_get_wks_col_names(crv, strX, strY); 
					out_str("The first DataPlot in Graph1: ");
					out_str("X: "+ strWks + "_" + strX);
					out_str("Y: "+ strWks + "_" + strY);
				}
			}
		}
	Parameters:
		cuv = [in] Curve to find info about
		strX = [out] X column name, can be empty if Curve has no X column
		strY = [out] Y column name.
	Return:
		name of the Worksheet, will be empty if input Curve is invalid
*/
string curve_get_wks_col_names(const curvebase& cuv, string& strX, string& strY);

/** >Curve
		Search the layer where two curves are both plotted.
	Parameters:
		cuv1 = [in] Curve to try to add to another curve's layer
		cuv2 = [in] Curve that is likely already plotted in some layer
		glayerFound = [out] Graph that cuv2 is currently plotted
	Example:
		if(cuvFit)
		{
			GraphLayer gl;
			if(!curve_both_in_layer(cuvFit, cuvData, gl) && gl) // there maybe many, we will just use 1st for now
			{
				// cuvData plotted in gl but cuvFit not, so we will make the plot
				int nPlot = gl.AddPlot(cuvFit, IDM_PLOT_LINE);
				DataPlot dp = gl.DataPlots(nPlot);
				dp.SetColor(1); // set to red
			}
		}
	Return:
		FALSE if not in same layer, or cuv2 not plotted at all
	Remark:
		glayerFound can be set to a layer to search first, or it can be let uninitialized	
*/
bool curve_both_in_layer(const curvebase& cuv1, const curvebase& cuv2, GraphLayer& glayerFound);

/** >Curve
	find the input curve layer and plot the result curve
	Parameters:
		cuvResult = [in] Curve to plot
		cuvInput = [in] reference Curve to find where to plot the cuvResult
		trInput  = [in] if given, this will provide the graph layer location to plot cuvResult
		nColor = [in] color of the cuvResult curve
		bRescale = [in] rescale layer or not
	Example:
		//This example shows how to plot Data1_C to the same graph layer as Data1_B in red.
		//For this sample codes to run, a worksheet named "Data1" with column B and C 
		//should exist in the current project and a graph with Data1_B plotted exists too.
		
		void run_curve_update()
		{
			Curve crvPlotted( "Data1_B" );
			Curve crvToBePlot( "Data1_C" );
			TreeNode trInput;
			int nColor = 1; 			//Red
			
			if(crvPlotted && crvToBePlot)
			{
				curve_update(crvToBePlot, crvPlotted, trInput, nColor);
			}

⌨️ 快捷键说明

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