Matrix::ImageLinesProfile

Description

Get intensity values over the course of a user defined path through this Matrix.

Syntax

int ImageLinesProfile( vector<fpoint> & vPathVertices, vector<fpoint> & vCalPoints, vectorbase & vIntensity, int iPointNumber = -1, int iMethod = INTERPOLATE_NEAREST )

Parameters

vPathVertices
[input] fpoint vector specifying the spatial coordinates (x,y) of the endpoints of the line segments making up the user defined path through the Matrix
vCalPoints
[output] fpoint vector containing fpoints used in calculation
vIntensity
[output] vector holding the intensity of the corresponding points in vCalPoints
iPointNumber
[input] The number of points used to calculate the profile lines (default -1 uses 1 point for each pixel that is traversed by path)
iMethod
[input] Determines interpolation method. An enumerated value from the system header file OC_const.h including the values INTERPOLATE_NEAREST, INTERPOLATE_BILINEAR, INTERPOLATE_BICUBIC, INTERPOLATE_2DSPLINE, and INTERPOLATE_VERTICINTERPOL

Return

Returns 0 on success and a non-zero error code on failure.

Examples

EX1

// Make the profile data of an image matrix
void Matrix_ImageLinesProfile_ex1()
{
    int ii,jj, nCols;
    int wNumRows=100, wNumCols=100;
    
    MatrixPage MatPg1;
    MatPg1.Create("Origin");
    MatrixLayer MatLy1 = MatPg1.Layers(0);
    Matrix Mat1(MatLy1);
    
    Mat1.SetSize( wNumRows, wNumCols );  //Set the number of rows and columns in matrix
    for(ii=0; ii<wNumRows; ii++)
        for(jj=0; jj<wNumCols; jj++)
            Mat1[ii][jj]=ii+2*jj;  
    MatLy1.SetViewImage();  //Set the view of the matrix to the Image Mode
    printf("%s is created in Image Mode.\n",Mat1.GetName());
    
    Mat1.SetXMin(0);
    Mat1.SetXMax(10);
    Mat1.SetYMin(0);
    Mat1.SetYMax(10);
    
    vector<fpoint> vPoints;
    vector<fpoint> vCalPoints;
    vector<double> vIntensity;

    //Define a '>'-shape parofile path: (0,0)-(10,5)-(0,10)
    vPoints.SetSize(3);
    vPoints[0].x = 0;
    vPoints[0].y = 0;
    vPoints[1].x = 10;
    vPoints[1].y = 5;
    vPoints[2].x = 0;
    vPoints[2].y = 10;

    Mat1.ImageLinesProfile(vPoints, vCalPoints, vIntensity, -1, INTERPOLATE_BILINEAR);

    nCols = vCalPoints.GetSize();
    
    Worksheet wks;
    wks.Create();
    wks.AddCol("C");
    Dataset myXDs(wks,0);
    Dataset myYDs(wks,1);
    Dataset myZDs(wks,2);
    String strYName = myYDs.GetName();
    String strWkbName = wks.GetName();
    String wksName=wks.GetPage().GetName();
    myXDs.SetSize(nCols);
    myYDs.SetSize(nCols);
    myZDs.SetSize(nCols);
        
    for(ii = 0; ii < nCols; ii++) {
        myXDs[ii]=vCalPoints[ii].x;    
        myYDs[ii]=vCalPoints[ii].y; 
        myZDs[ii]=vIntensity[ii]; 
    }
    printf("%s in %s has been created to store the profile data.\n",strWkbName,wksName);
    LT_execute("worksheet -s 2 0 3 0;worksheet -P 247 scatter;Spectrum");//Plot a color-mapped scatter
    printf("Color-mapped graph has been created to show the profile.\n",strWkbName,wksName);
}

Remark

Get intensity values over the course of a user defined path through this Matrix.

See Also

Matrix::GetInterpolatedValue

header to Include

origin.h