Exemple #1
0
//================================================================
void mexFunction(	int nlhs, mxArray *plhs[], 
					int nrhs, const mxArray*prhs[] ) 
//================================================================                    
{
	//------------------------------------------------------------------
	/* retrive arguments */
	//------------------------------------------------------------------
	if( (nrhs!=2)  )
    {
		mexErrMsgTxt("2 arguments are required.");
    }
	//------------------------------------------------------------------
	// first argument : Set of points
    if( (mxGetClassID(prhs[0]) != mxDOUBLE_CLASS) || (mxGetNumberOfDimensions(prhs[0])!= 2) 
		||    mxGetDimensions(prhs[0])[0] != 2 ) 
	{
			mexErrMsgTxt("tforth input shoud be an array containing the [mean_i, std_i] intensities of the nuclei regions") ;
	}
    
    POINTS = mxGetPr(prhs[0]);
    number_of_points = mxGetDimensions(prhs[0])[1];
	//------------------------------------------------------------------
	// Second argument : Distance map for the back propagation
    if( (mxGetClassID(prhs[1]) != mxDOUBLE_CLASS) || (mxGetNumberOfDimensions(prhs[1])!= 2) ) 
    {
        mexErrMsgTxt("Distance map for the back propagation must be a 2D double array AND \n must be of class double") ;
    }
    
	UU = (double*)mxGetPr(prhs[1]);
    nx = mxGetDimensions(prhs[1])[0];
	ny = mxGetDimensions(prhs[1])[1];
	Nx = nx+2; Ny = ny+2;
	size = Nx*Ny;
	//------------------------------------------------------------------
    //==================================================================
	// Outputs
	mwSize dims[2] = {Nx,Ny};
	// First output : minimal action map
	plhs[0] = mxCreateNumericArray(2, dims, mxLOGICAL_CLASS, mxREAL );
	Filaments = (bool*) mxGetPr(plhs[0]);
	//==================================================================
	InitializeNeighborhoods();
    //------------------------------------------------------------------
	InitializeArrays();
    	//------------------------------------------------------------------
 	BackPropagate();
	//==================================================================
	resize();
	dims[0] = Nx-2; dims[1] = Ny-2;
	mxSetDimensions(plhs[0], dims, 2);
	//==================================================================
    mxFree(U);
    mxFree(NeighborhoodLarge);
    mxFree(END_POINTS);
    return;
}
//-------------------------------------------------------------------------
void mexFunction(	int nlhs, mxArray *plhs[], 
					int nrhs, const mxArray*prhs[] ) 
//-------------------------------------------------------------------------
{
    //------------------------------------------------------------------
	/* retrive arguments */
	//------------------------------------------------------------------
	if( nrhs!=3 )
		mexErrMsgTxt("3 arguments are required.");
	if( mxGetNumberOfDimensions(prhs[1])!= 2 )
		mexErrMsgTxt("Image must be a 2D double array.");
	//------------------------------------------------------------------
	// first argument : spacing and dimensions
	const int* dim_h = mxGetDimensions(prhs[0]);
    if ( (dim_h[0]!=2) || (dim_h[1]!=1) )
	  mexErrMsgTxt("Library error: h must be a 2x1 array list.");
	hx = mxGetPr(prhs[0])[0]; hy = mxGetPr(prhs[0])[1];
	hx2 = hx*hx; hy2 = hy*hy;
    hxhy = hx*hy;
	Nx = mxGetDimensions(prhs[1])[0];
	Ny = mxGetDimensions(prhs[1])[1];
    NxNy = Nx*Ny;
	//------------------------------------------------------------------
	// Second argument : Image
	Image = (double*) mxGetPr(prhs[1]);
	//------------------------------------------------------------------
	// Third argument : Set of scales
	if(mxGetDimensions(prhs[2])[0] != 1)
        mexErrMsgTxt("The input radii list must be a 1xN array list.");
    N_Radius = mxGetDimensions(prhs[2])[1];
    Radius = (double*) mxGetPr(prhs[2]);
	//------------------------------------------------------------------
	// Fourth argument : the tolerance gives the window size
	halfWindow = 3;//floor(sigma*sqrt(-2*log(epsilon))) + 1;
    //==================================================================
	// Outputs
	int dims[4] = {Nx,Ny,3, N_Radius};
	//------------------------------------------------------------------
	// First output : Matrice Hessienne
	plhs[0] = mxCreateNumericArray(4, dims, mxDOUBLE_CLASS, mxREAL );
	Hessian = (double*) mxGetPr(plhs[0]);
	//==================================================================
	InitializeArrays();
	//------------------------------------------------------------------
	Compute_Hessian_Matrix();
    //==================================================================
    DELETEARRAY(kernelGxx); DELETEARRAY(kernelGyy); DELETEARRAY(kernelGxy);
    DELETEARRAY(H);
	return;
};
Exemple #3
0
int main()
{
  
  // Sorting array with 100 values already sorted low to high
  // with Selection Sort

  int SIZE_HUNDRED = 100;
  int testArray[SIZE_HUNDRED];

  int testArray2[SIZE_HUNDRED];

  int testArrayRandom[SIZE_HUNDRED];

  int SIZE_THOUSAND = 1000;
  int testArrayThousand[SIZE_THOUSAND];

  int testArrayThousand2[SIZE_THOUSAND];
 
  int testArrayThousandRandom[SIZE_THOUSAND];

  InitializeArrays( testArray, testArray2, testArrayRandom,testArrayThousand,  testArrayThousand2, testArrayThousandRandom);


  int nA = sizeof(testArray)/sizeof(aType);

  cout << "nA: "  << nA << endl;

  cout << "Initial array contents:" << endl;
  PrintArray( testArray, nA );
 
  
  //  cout << "Sorting with merge sort." << endl;
  // Mergesort( testArray, 0, nA-1 );  

  //cout << "Final array contents:" << endl;
  //PrintArray( testArrayThousandRandom, nA );


  InitializeArrays( testArray, testArray2, testArrayRandom,testArrayThousand,  testArrayThousand2, testArrayThousandRandom);

  cout << "Sorting with quick sort." << endl;
  Quicksort( testArray, 0, nA-1 );  

  cout << "Final array contents:" << endl;
  PrintArray( testArray, nA );

  InitializeArrays( testArray, testArray2, testArrayRandom,testArrayThousand,  testArrayThousand2, testArrayThousandRandom);

  cout << "Sorting with selection sort." << endl;
  SelectionSort( testArray, nA );

  cout << "Final array contents:" << endl;
  PrintArray( testArray, nA );

  
  // Sorting array with 100 values already sorted high to low
  // with selection sort
  int nB = sizeof(testArray2)/sizeof(aType);

  InitializeArrays( testArray, testArray2, testArrayRandom,testArrayThousand,  testArrayThousand2, testArrayThousandRandom);


  cout << "nB: "  << nB << endl;

  cout << "Initial array contents:" << endl;
  PrintArray( testArray2, nB );

  //cout << "Sorting with merge sort." << endl;
  //Mergesort( testArray2, 0, nB-1 );  

  //  cout << "Final array contents:" << endl;
  //  PrintArray( testArray2, nB );

  InitializeArrays( testArray, testArray2, testArrayRandom,testArrayThousand,  testArrayThousand2, testArrayThousandRandom);

  cout << "Sorting with quick sort." << endl;
  Quicksort( testArray2, 0, nB-1 );  

  cout << "Final array contents:" << endl;
  PrintArray( testArray2, nB );

  InitializeArrays( testArray, testArray2, testArrayRandom,testArrayThousand,  testArrayThousand2, testArrayThousandRandom);
  
  cout << "Sorting with selection sort." << endl;
  SelectionSort( testArray2, nB );

  cout << "Final array contents:" << endl;
  PrintArray( testArray2, nB );

  // Sorting array with 100 random values
  int nE = sizeof(testArrayRandom)/sizeof(aType);

  InitializeArrays( testArray, testArray2, testArrayRandom,testArrayThousand,  testArrayThousand2, testArrayThousandRandom);


  cout << "nE: "  << nE << endl;

  cout << "Initial array contents:" << endl;
  PrintArray( testArrayRandom, nE );

  //cout << "Sorting with merge sort." << endl;
  //Mergesort( testArrayRandom, 0, nE-1 );  

  //  cout << "Final array contents:" << endl;
  //  PrintArray( testArrayRandom, nE );

  InitializeArrays( testArray, testArray2, testArrayRandom,testArrayThousand,  testArrayThousand2, testArrayThousandRandom);

  cout << "Sorting with quick sort." << endl;
  Quicksort( testArrayRandom, 0, nE-1 );  

  cout << "Final array contents:" << endl;
  PrintArray( testArrayRandom, nE );

  InitializeArrays( testArray, testArray2, testArrayRandom,testArrayThousand,  testArrayThousand2, testArrayThousandRandom);

  cout << "Sorting with selection sort." << endl;
  SelectionSort( testArrayRandom, nE );

  cout << "Final array contents:" << endl;
  PrintArray( testArrayRandom, nE );


  // Sorting array with 1000 values already sorted low to high
  // with Selection Sort

  int nC = sizeof(testArrayThousand)/sizeof(aType);

  InitializeArrays( testArray, testArray2, testArrayRandom,testArrayThousand,  testArrayThousand2, testArrayThousandRandom);


  cout << "nC: "  << nC << endl;

  cout << "Initial array contents:" << endl;
  PrintArray( testArrayThousand, nC );

  //cout << "Sorting with merge sort." << endl;
  //Mergesort( testArrayThousand, 0, nC-1 );  

  //  cout << "Final array contents:" << endl;
  //  PrintArray( testArrayThousand, nC );

  InitializeArrays( testArray, testArray2, testArrayRandom,testArrayThousand,  testArrayThousand2, testArrayThousandRandom);

  cout << "Sorting with quick sort." << endl;
  Quicksort( testArrayThousand, 0, nC-1 );  

  cout << "Final array contents:" << endl;
  PrintArray( testArrayThousand, nC );

  InitializeArrays( testArray, testArray2, testArrayRandom,testArrayThousand,  testArrayThousand2, testArrayThousandRandom);
  
  cout << "Sorting with Selection sort. " << endl;
  SelectionSort( testArrayThousand, nC );

  cout << "Final array contents:" << endl;
  PrintArray( testArrayThousand, nC );


  // Sorting array with 1000 values already sorted low to high
  // with Selection Sort

  int nD = sizeof(testArrayThousand2)/sizeof(aType);

  InitializeArrays( testArray, testArray2, testArrayRandom,testArrayThousand,  testArrayThousand2, testArrayThousandRandom);


  cout << "nD: "  << nD << endl;

  cout << "Initial array contents:" << endl;
  PrintArray( testArrayThousand2, nD );

  //cout << "Sorting with merge sort." << endl;
  //Mergesort( testArrayThousand2, 0, nD-1 );  

  //  cout << "Final array contents:" << endl;
  //  PrintArray( testArrayThousand2, nD );

  InitializeArrays( testArray, testArray2, testArrayRandom,testArrayThousand,  testArrayThousand2, testArrayThousandRandom);

  cout << "Sorting with quick sort." << endl;
  Quicksort( testArrayThousand2, 0, nD-1 );  

  cout << "Final array contents:" << endl;
  PrintArray( testArrayThousand2, nD );

  InitializeArrays( testArray, testArray2, testArrayRandom,testArrayThousand,  testArrayThousand2, testArrayThousandRandom);

  cout << "Sorting with selection sort." << endl;
  SelectionSort( testArrayThousand2, nD );

  cout << "Final array contents:" << endl;
  PrintArray( testArrayThousand2, nD );

    // Sorting array with 1000 random values

  int nF = sizeof(testArrayThousandRandom)/sizeof(aType);

  InitializeArrays( testArray, testArray2, testArrayRandom,testArrayThousand,  testArrayThousand2, testArrayThousandRandom);

  cout << "nF: "  << nF << endl;

  cout << "Initial array contents:" << endl;
  PrintArray( testArrayThousandRandom, nF );

  //cout << "Sorting with merge sort." << endl;
  //Mergesort( testArrayThousandRandom, 0, nF-1 );  

  //  cout << "Final array contents:" << endl;
  //  PrintArray( testArrayThousandRandom, nF );

  cout << "Final array contents:" << endl;
  PrintArray( testArrayThousandRandom, nF );

  InitializeArrays( testArray, testArray2, testArrayRandom,testArrayThousand,  testArrayThousand2, testArrayThousandRandom);

  cout << "Sorting with quick sort." << endl;
  Quicksort( testArrayThousandRandom, 0, nF-1 );  

  cout << "Final array contents:" << endl;
  PrintArray( testArrayThousandRandom, nF );

  InitializeArrays( testArray, testArray2, testArrayRandom,testArrayThousand,  testArrayThousand2, testArrayThousandRandom);

  cout << "Sorting with selection sort." << endl;
  SelectionSort( testArrayThousandRandom, nF );

  cout << "Final array contents:" << endl;
  PrintArray( testArrayThousandRandom, nF );

  
  /*
  aType testArray[] = { 7, 13, 1, 3, 10, 5, 2, 4 };
  int nA = sizeof(testArray)/sizeof(aType);

  cout << "nA: "  << nA << endl;

  cout << "Initial array contents:" << endl;
  PrintArray( testArray, nA );

  SelectionSort( testArray, nA );

  cout << "Final array contents:" << endl;
  PrintArray( testArray, nA );
  */


  
  return 0;
}