資源簡介
線積分卷積,可以利用白噪聲圖像實現二維向量矩陣的可視化,多用于流體研究。

代碼片段和文件信息
#include?“stdafx.h“
#include?
#include?
#include?
#include?
#define??SQUARE_FLOW_FIELD_SZ 400
#define ?DISCRETE_FILTER_SIZE 2048
#define??LOWPASS_FILTR_LENGTH 10.00000f
#define ?LINE_SQUARE_CLIP_MAX 100000.0f
#define ?VECTOR_COMPONENT_MIN???0.050000f?
void?????SyntheszSaddle(int??n_xres??int?????n_yres??float*???pVectr);
void ?NormalizVectrs(int??n_xres??int?????n_yres??float*???pVectr);
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*???pVectr???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_xres?*?n_yres?*?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);
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;
}
/// synthesize?a?saddle-shaped?vector?field?????///
void SyntheszSaddle(int??n_xres??int??n_yres??float*??pVectr)
{???
for(int??j?=?0;??j????? for(int??i?=?0;??i? {
int ?index?=?(??(n_yres?-?1?-?j)?*?n_xres?+?i??)??<?1;
pVectr[index????]?=?-?(?j?/?(n_yres?-?1.0f)?-?0.5f?);
pVectr[index?+?1]?=?????i?/?(n_xres?-?1.0f)?-?0.5f;
???? }
}
/// normalize?the?vector?field?????///
void????NormalizVectrs(int??n_xres??int??n_yres??float*??pVectr)
{
for(int ?j?=?0;??j????? for(int ?i?=?0;??i????? {
int index?=?(j?*?n_xres?+?i)?<1;
???????? float vcMag?=?float(??sqrt(?double(pVectr[index]?*?pVectr[index]?+?pVectr[index?+?1]?*?pVectr[index?+?1])?)??);
float scale?=?(vcMag?==?0.0f)???0.0f?:?1.0f?/?vcMag;
pVectr[index????]?*=?scale;
????????????pVectr[index?+?1]?*=?scale;
???? }
}
/// make?white?noise?as?the?LIC?input?texture?????///
void MakeWhiteNoise(int??n_xres??int??n_yres??unsigned?cha
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????769??2009-02-16?17:43??LIC\StdAfx.h
?????文件????????290??2009-02-16?17:43??LIC\StdAfx.cpp
?????文件???????1190??2009-02-16?17:43??LIC\ReadMe.txt
?????文件????????529??2009-02-16?17:43??LIC\LIC.dsw
?????文件??????33792??2009-02-16?17:46??LIC\LIC.ncb
?????目錄??????????0??2009-02-16?17:43??LIC\Debug
?????文件???????9948??2009-02-16?17:44??LIC\LIC.cpp
?????文件????????889??2009-02-16?17:46??LIC\LIC.plg
?????文件???????4542??2009-02-16?17:45??LIC\LIC.dsp
?????文件?????480018??2009-02-16?17:46??LIC\LIC.ppm
?????文件??????48640??2009-02-16?17:46??LIC\LIC.opt
?????目錄??????????0??2009-02-16?17:43??LIC
-----------?---------??----------?-----??----
???????????????580607????????????????????12
- 上一篇:CATIA和RADE(CAA)破解補丁及說明
- 下一篇:基于stm32的音樂頻譜顯示
評論
共有 條評論