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

📄 fast_int.c

📁 FIELD II 是B超的matlab仿真程序。 执行 先运行 field_init.m
💻 C
📖 第 1 页 / 共 2 页
字号:
	   weight_coef[ij_index_coef + 1] =    samp_val *(1-line_val)*scaling;	   weight_coef[ij_index_coef + 2] = (1-samp_val)* line_val   *scaling;	   weight_coef[ij_index_coef + 3] =    samp_val * line_val   *scaling;           index_samp_line[ij_index] = index_samp + index_line*N_samples;	   image_index[ij_index] = (Nx-j-1)*Nz + i;           ij_index++;           ij_index_coef = ij_index_coef + 4;	  }	x = x + dx;       }     z = z + dz;    }  *N_values = ij_index;  printf ("Table has now been set-up, %d x %d, %d %d values\n",Nz,Nx,ij_index,*N_values);     }         /*--------------------------------------------------------*/         /*  Function for making the actual image interpolation    */	 /*  It is assumed that the image has been previously      */	 /*  initialized.                                          */         /*--------------------------------------------------------*/void make_interpolation (unsigned char  *envelope_data,   /*  The envelope detected and log-compressed data */		         int            N_samples,        /*  Number of samples in one envelope line        */			 		         int            *index_samp_line, /*  Index for the data sample number              */		         int            *image_index,     /*  Index for the image matrix                    */                         float          *weight_coef,     /*  The weight table                              */                         int            N_values,         /*  Number of values to calculate in the image      */			                          unsigned char *image)            /*  The resulting image                           */{int           i;                 /*  Integer loop counter                */ int           ij_index_coef;     /*  Index into coefficient array        */ unsigned char *env_pointer;      /*  Pointer to the envelope data        */ float         *weight_pointer;   /*  Pointer to the weight coefficients  */   ij_index_coef = 0;  for (i=0; i<N_values; i++)    {     weight_pointer = &(weight_coef[ij_index_coef]);     env_pointer = &(envelope_data[index_samp_line[i]]);     image[image_index[i]]               =         weight_pointer[0] * env_pointer[0]                      + weight_pointer[1] * env_pointer[1]                      + weight_pointer[2] * env_pointer[N_samples]                      + weight_pointer[3] * env_pointer[N_samples+1] + 0.5;     ij_index_coef = ij_index_coef + 4;    }}  /*--------------------------------------------------------------------------*/  /*  Function called by Matlab when the matlab m-file fast_int is called.    */  /*  See the Matlab documentation for further explanation.                   */  /*                                                                          */  /*  Arguments:                                                              */  /*      nlhs - Number of left hand arguments, i.e., output variables.       */  /*      plhs - Pointers to the left hand arguments.                         */  /*                                                                          */  /*      nrhs - Number of right hand arguments, i.e., input variables.       */  /*      prhs - Pointers to the right hand arguments.                        */  /*--------------------------------------------------------------------------*/  void mexFunction(int  nlhs,         mxArray  *plhs[],                 int  nrhs,   const mxArray  *prhs[]) {int main_code;    /*  Code for the module called   */                   /*   1 - Table definition        */                   /*   2 - Image interpolation     */		    unsigned char *envelope_data;  /*  Pointer to the envelope detected and log-compressed data */ int           dimension[2];    /*  Dimension of the resulting array                         */ 	/* Check for proper number of arguments */  if (nrhs == 0)      mexErrMsgTxt("Error 1: Illegal calling of the fast_int mex-code");        /*  Get the function code and the main code   */  main_code = floor(mxGetScalar (prhs[0]) + 0.5);       /*  Branch out to the different modules         */   switch (main_code)      {           /*   Make the tables for image interpolation  */      case 1:{              if ((nrhs<2) && (nlhs<1))                mexErrMsgTxt("Error 5: Too few input parameters to make interpolation tables");              else                {                    /*  Decode the variables for the table  */		                     start_depth = mxGetScalar (prhs[1]);            /*  Depth for start of image in meters    */	         image_size = mxGetScalar (prhs[2]);             /*  Size of image in meters               */		   	         start_of_data = mxGetScalar (prhs[3]);          /*  Depth for start of data in meters     */	         delta_r = mxGetScalar (prhs[4]);                /*  Sampling interval for data in meters  */	         N_samples = floor(mxGetScalar (prhs[5]) + 0.5); /*  Number of samples in one envelope line*/		   	         theta_start = mxGetScalar (prhs[6]);            /*  Angle for first line in image         */	         delta_theta = mxGetScalar (prhs[7]);            /*  Angle between individual lines        */	         N_lines = floor(mxGetScalar (prhs[8]) + 0.5);   /*  Number of acquired lines              */		   	         scaling = mxGetScalar (prhs[9]);                /*  Scaling factor form envelope to image */	         Nz = floor(mxGetScalar (prhs[10]) + 0.5);       /*  Size of image in pixels               */	         Nx = floor(mxGetScalar (prhs[11]) + 0.5);       /*  Size of image in pixels               */	                         /*  Call the procedure and make the table  */			         make_tables (start_depth, image_size, 		              start_of_data, delta_r, N_samples, 		              theta_start, delta_theta, N_lines, 		              scaling, Nz, Nx,		              weight_coef, index_samp_line, image_index, &N_values);	                        table_set_up = 1;                 }	      break;	     }	                  /*   Make image interpolation                  */      case 2:{               if (table_set_up != 1)                 mexErrMsgTxt("Error 3: Table not set-up before calling make_interpolation, call make_tables first.");	      else	          if ((nrhs<2) && (nlhs<1))                    mexErrMsgTxt("Error 4: Too few input and output parameters to make interpolation");                  else                    {		       /*  Decode the variables before calling   */		     envelope_data = (unsigned char *) mxGetPr (prhs[1]);      /*  The envelope detected and log-compressed data */		     		       /*  Create the array that should hold the output image  */		       		     dimension[0]=Nz;		     dimension[1]=Nx;		     plhs[0]  = mxCreateNumericArray(2, dimension, mxUINT8_CLASS, mxREAL);                     make_interpolation (envelope_data, N_samples,		      	                 index_samp_line, image_index, weight_coef, N_values, 			                 (unsigned char *) mxGetPr(plhs[0]));		   }		break;	       }      default: {mexErrMsgTxt("Internal Error 2: Illegal main_code found in fast_int.");               break;               }       }  return;} 

⌨️ 快捷键说明

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