# 2.2.4.24.26 Layer::MakeLineProfile

## Description

It computes profile of the image or matrix, including, possibly, averaging over a moving window around a point, and the standard deviation withing the window.

## Syntax

int MakeLineProfile( vector<int> & vnRows, vector<int> & vnCols, OImageMakeLineProfileParams * pstParams, matrix & matOut, matrix & matOutAux = NULL )

## Parameters

vnRows
[input] the row indices of the points within the image where the profile is to be computed.
vnCols
[input] the column indices of the points within the image where the profile is to be computed. It must be of the same size as vnRows.
pstParams
struct OImageMakeLineProfileParams
{
//They are used only if the line of points is horizontal or vertical.
//They are the number of points BEFORE(Behind) or AFTER(Ahead) the current point in the same direction
//as other points, which should be averaged over to produce the final result.
//For example, if vnRows and vnCols produce a vertical line(which means all the values in vnCols are the same)
//then this variable determines how many rows before and after the current point's row are averaged over.
int nPtsBehind;

//They are used only if the line of points is horizontal or vertical.
//They are the number of points BEFORE or AFTER the current point
//n the perpendicular direction of all other points which should be
//averaged over to produce the final result. For example, if vnRows
//and vnCols produce a vertical line(which means all the values in vnCols are the same)
//then this variable determines how many columns before and after
//the all point's column are averaged over.

//These are used ONLY for lines of points that are vetical (all the
//values in vnCols are the same) or horizontal (all the values in vnRows are the same),
//otherwise they are not used, i.e. there is no averaging and the
//value of the profile at the current point equals the value of the pixel at that position.
int nPtsSideBefore;
int nPtsSideAfter;

//Used if the line of points is neither horizontal nor vertical -
//it represents the radius around the current point to determine
//which neighboring points ought to be included in averaging.
//If 0, only the input point is put into the output.
}
matOut
[output] the profile: the number of of rows equals the number of points in the arrays vnRows, vnCols; the number of columns equals the number of frames in the image.
matOutAux
[output] the standard deviation over the averaging window if there is any averaging (see pstParams above) for every point. If no avearging, it will contain missing values. The meaning of rows and columns is the same as for matOut.

## Return

0 if success, otherwise FALSE.

## Examples

EX1

void	test_arbitrary_line_profile(int nFixedPos = 10, int nWidth=3, int bVertical = 1)
{
ImageLayer imglayer = Project.ActiveLayer();
if (!imglayer.IsValid())
{
out_str("Inavlid Active Window!");
return;
}
int nW = imglayer.GetProp("Width");
int nH = imglayer.GetProp("Height");
int nCount = nH;
if(bVertical==0)
nCount = nW;
vector<int>		vnRows;
vector<int>		vnCols;
vnRows.Data(0, nCount - 1);
vnCols.Data(0, nCount - 1);

OImageMakeLineProfileParams	params;
params.nPtsBehind = 2;
params.nPtsSideBefore = 0;
params.nPtsSideAfter = nWidth;
matrix matOut, matOutAux;
int nRet = imglayer.MakeLineProfile(vnRows, vnCols, &params, matOut, matOutAux);

MatrixPage mp;
mp.Create("Origin");
Matrix matA;
matA.Attach(mp.GetName());
matA = matOut;

MatrixPage mp2;
mp2.Create("Origin");
Matrix matB;
matB.Attach(mp2.GetName());
matB = matOutAux;

return;
}