Home > Software engineering >  Lic (first integral convolution) specific interpretation and how to use a method
Lic (first integral convolution) specific interpretation and how to use a method

Time:10-19

Have a great god can tell lic (line integral convolution) specific interpretation of the code and how to use, or recommend a detailed explanation lic code * * * * specific algorithm process papers or url, seen a lot of papers didn't mention the specific algorithm process, and lic code for less, ask the great spirit guide, under the supplementary lic code
#include
#include
#include
#include
#include
# define SQUARE_FLOW_FIELD_SZ 400
2048//# define DISCRETE_FILTER_SIZE corresponding item convolution kernels, if too small some sample point it hadn't been convolution, influence the image effect
# define LOWPASS_FILTR_LENGTH 32.00000 f
# define LINE_SQUARE_CLIP_MAX f/100000.0/just greater than or equal to zero, equal to zero when a black lines
# define VECTOR_COMPONENT_MIN 0.050000 f
/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - */
Void SyntheszSaddle (int n_xres, int n_yres, float * pVector);
Void NormalizVectrs (int n_xres, int n_yres, float * pVector);
Void GenBoxFiltrLUT (int LUTsiz, float * p_LUT0, float * p_LUT1);
Void MakeWhiteNoise (int n_xres, int n_yres, unsigned char * pNoise);
Void FlowImagingLIC (int n_xres, int n_yres, float * pVector, unsigned char * pNoise,
Unsigned char * pImage, float * p_LUT0, float * p_LUT1, float krnlen);
Void WriteImage2PPM (int n_xres, int n_yres, unsigned char * pImage, char * f_name);
/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - */
/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - */
Void main ()
{
Int n_xres=SQUARE_FLOW_FIELD_SZ;
Int n_yres=SQUARE_FLOW_FIELD_SZ;
Float * pVectr=(float *) malloc (sizeof (float) * n_yres n_xres * * 2);
Float * p_LUT0=(float *) malloc (sizeof (float) * DISCRETE_FILTER_SIZE);
Float * p_LUT1=(float *) malloc (sizeof (float) * DISCRETE_FILTER_SIZE);
Unsigned char * pNoise=(unsigned char *) malloc (sizeof (unsigned char) * n_xres * n_yres);
Unsigned char * pImage=(unsigned char *) malloc (sizeof (unsigned char) * n_xres * n_yres);
SyntheszSaddle (n_xres n_yres, pVectr);
//NormalizVectrs (n_xres n_yres, pVectr);/* data irregular words, the smaller the speed of the noise is strong
MakeWhiteNoise (n_xres n_yres, pNoise);
GenBoxFiltrLUT (DISCRETE_FILTER_SIZE p_LUT0, p_LUT1);
FlowImagingLIC (n_xres n_yres, pVectr pNoise, pImage, p_LUT0, p_LUT1, LOWPASS_FILTR_LENGTH);
WriteImage2PPM (n_xres, n_yres pImage, "LIC. PPM");

Free (pVectr); PVectr=NULL;
Free (p_LUT0); P_LUT0=NULL;
Free (p_LUT1); P_LUT1=NULL;
Free (pNoise); PNoise=NULL;
Free (pImage); PImage=NULL;
}
/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - */
Synthetic data/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
Void SyntheszSaddle (int _row, int _col, float * pVectr)
{
Int row=400, col=400, index=0;
Float vec_x=0.0 f, vec_y=0.0 f, vcMag=0.0 f, scale=0.0 f;
for(int i=0; I & lt; The row. I++)
{
For (int j=0; J & lt; Col. J++)
{
//data generation
The index=I * col + j;//center vector field
//index=(row 1 - I) * col + j.//saddle vector field
Vec_x=- (float) I/row + 0.5 f;
Vec_y=(float) j/col - 0.5 f;
//data structured
VcMag=float (SQRT (vec_x + vec_y vec_x * * vec_y));
Scale=(vcMag & lt; 0.001 f)? F: 0.0 f/1.0 vcMag;
Vec_x *=scale;
Vec_y *=scale;

PVectr [2 * index]=vec_x;
PVectr index + 1] [2 *=vec_y;
}
}
}
/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
/* data structured -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - */
Void NormalizVectrs (int n_xres, int n_yres, float * pVectr)
{
For (int j=0; J & lt; N_yres; J++)
{
for(int i=0; i{
Int index=(j * n_xres + I) & lt; <1;
Float vcMag=float (SQRT (double (pVectr pVectr [index] * [index] + pVectr pVectr [index + 1] * [index + 1))));
Float scale=(vcMag==0.0 f)? F: 0.0 f/1.0 vcMag;
PVectr [index]=scale; Magnification,//vector component, the greater the speed, the greater the program running speed will slow, but the effect will be more clear
PVectr [index + 1) *=scale;
}//for
}//for
}
/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - */
/* generate white noise -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
Void MakeWhiteNoise (int n_xres, int n_yres, unsigned char * pNoise)
{
For (int j=0; J & lt; N_yres; J++)
{
for(int i=0; i{
Int r=rand ();
R=((r & amp; 0 XFF) + ((r & amp; 0 xff00) & gt;> 8)) & amp; 0 XFF.//
PNoise [j * n_xres + I]=(unsigned char) r;
}
}
}
/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - */
/* convolution kernels LUTsiz=DISCRETE_FILTER_SIZE -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
Void GenBoxFiltrLUT (int LUTsiz, float * p_LUT0, float * p_LUT1)
{
for(int i=0; I & lt; LUTsiz; I++)
{
P_LUT0 [I]=p_LUT1 [I]=(float) I;
}
}
/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - */
/* write file -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related