本文整理汇总了C++中CImgList::load方法的典型用法代码示例。如果您正苦于以下问题:C++ CImgList::load方法的具体用法?C++ CImgList::load怎么用?C++ CImgList::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CImgList
的用法示例。
在下文中一共展示了CImgList::load方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
// Main procedure
//----------------
int main(int argc,char **argv) {
// Read and init data
//--------------------
cimg_usage("A viewer of Diffusion-Tensor MRI volumes.");
const char *file_i = cimg_option("-i",(char*)0,"Input : Filename of tensor field (volume wxhxdx6)");
const char* vsize = cimg_option("-vsize","1x1x1","Input : Voxel aspect");
const bool normalize = cimg_option("-normalize",true,"Input : Enable tensor normalization");
const char *file_f = cimg_option("-f",(char*)0,"Input : Input fibers\n");
const float dl = cimg_option("-dl",0.5f,"Fiber computation : Integration step");
const float famin = cimg_option("-famin",0.3f,"Fiber computation : Fractional Anisotropy threshold");
const float cmin = cimg_option("-cmin",0.2f,"Fiber computation : Curvature threshold");
const float lmin = cimg_option("-lmin",10.0f,"Fiber computation : Minimum length\n");
const float lmax = cimg_option("-lmax",1000.0f,"Fiber computation : Maximum length\n");
const float tfact = cimg_option("-tfact",1.2f,"Display : Tensor size factor");
const char *bgcolor = cimg_option("-bg","0,0,0","Display : Background color");
unsigned int bgr = 0, bgg = 0, bgb = 0;
std::sscanf(bgcolor,"%u%*c%u%*c%u",&bgr,&bgg,&bgb);
CImg<> tensors;
if (file_i) {
std::fprintf(stderr,"\n- Loading tensors '%s'",cimg::basename(file_i));
tensors.load(file_i);
} else {
// Create a synthetic tensor field here
std::fprintf(stderr,"\n- No input files : Creating a synthetic tensor field");
tensors.assign(32,32,32,6);
cimg_forXYZ(tensors,x,y,z) {
const float
u = x - tensors.width()/2.0f,
v = y - tensors.height()/2.0f,
w = z - tensors.depth()/2.0f,
norm = (float)std::sqrt(1e-5f + u*u + v*v + w*w),
nu = u/norm, nv = v/norm, nw = w/norm;
const CImg<>
dir1 = CImg<>::vector(nu,nv,nw),
dir2 = CImg<>::vector(-nv,nu,nw),
dir3 = CImg<>::vector(nw*(nv - nu),-nw*(nu + nv),nu*nu + nv*nv);
tensors.set_tensor_at(2.0*dir1*dir1.get_transpose() +
1.0*dir2*dir2.get_transpose() +
0.7*dir3*dir3.get_transpose(),
x,y,z);
}
}
float voxw = 1, voxh = 1, voxd = 1;
std::sscanf(vsize,"%f%*c%f%*c%f",&voxw,&voxh,&voxd);
std::fprintf(stderr," : %ux%ux%u image, voxsize=%gx%gx%g.",
tensors.width(),tensors.height(),tensors.depth(),
voxw,voxh,voxd);
CImgList<> fibers;
if (file_f) {
std::fprintf(stderr,"\n- Loading fibers '%s'.",cimg::basename(file_f));
fibers.load(file_f);
}
const CImg<unsigned char> fiber_palette =
CImg<>(2,1,1,3).fill(200,255,0,255,0,200).RGBtoHSV().resize(256,1,1,3,3).HSVtoRGB();
// Compute eigen elements
//------------------------
std::fprintf(stderr,"\n- Compute eigen elements.");
CImg<unsigned char> coloredFA(tensors.width(),tensors.height(),tensors.depth(),3);
CImg<> eigen(tensors.width(),tensors.height(),tensors.depth(),13);
CImg<> val,vec;
float eigmax = 0;
cimg_forXYZ(tensors,x,y,z) {
tensors.get_tensor_at(x,y,z).symmetric_eigen(val,vec);
eigen(x,y,z,0) = val[0]; eigen(x,y,z,1) = val[1]; eigen(x,y,z,2) = val[2];
if (val[0]<0) val[0] = 0;
if (val[1]<0) val[1] = 0;
if (val[2]<0) val[2] = 0;
if (val[0]>eigmax) eigmax = val[0];
eigen(x,y,z,3) = vec(0,0); eigen(x,y,z,4) = vec(0,1); eigen(x,y,z,5) = vec(0,2);
eigen(x,y,z,6) = vec(1,0); eigen(x,y,z,7) = vec(1,1); eigen(x,y,z,8) = vec(1,2);
eigen(x,y,z,9) = vec(2,0); eigen(x,y,z,10) = vec(2,1); eigen(x,y,z,11) = vec(2,2);
const float fa = get_FA(val[0],val[1],val[2]);
eigen(x,y,z,12) = fa;
const int
r = (int)cimg::min(255.0f,1.5f*cimg::abs(255*fa*vec(0,0))),
g = (int)cimg::min(255.0f,1.5f*cimg::abs(255*fa*vec(0,1))),
b = (int)cimg::min(255.0f,1.5f*cimg::abs(255*fa*vec(0,2)));
coloredFA(x,y,z,0) = (unsigned char)r;
coloredFA(x,y,z,1) = (unsigned char)g;
coloredFA(x,y,z,2) = (unsigned char)b;
}