本文整理汇总了C++中volume::max方法的典型用法代码示例。如果您正苦于以下问题:C++ volume::max方法的具体用法?C++ volume::max怎么用?C++ volume::max使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类volume
的用法示例。
在下文中一共展示了volume::max方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: min
volume<float> draw_mesh_bis(const volume<float>& image, const Mesh &m)
{
double xdim = (double) image.xdim();
double ydim = (double) image.ydim();
double zdim = (double) image.zdim();
double mininc = min(xdim,min(ydim,zdim)) * .5;
volume<float> res = image;
double max = image.max();
for (list<Triangle*>::const_iterator i = m._triangles.begin(); i!=m._triangles.end(); i++)
{
Vec n = (*(*i)->get_vertice(0) - *(*i)->get_vertice(1));
double d = n.norm();
n.normalize();
for (double j=0; j<=d; j+=mininc)
{
Pt p = (*i)->get_vertice(1)->get_coord() + j* n;
draw_segment_bis(res, p, (*i)->get_vertice(2)->get_coord(), max);
}
}
return res;
}
示例2: t1only_write_ext_skull
//writes externall skull computed from image on output.
void t1only_write_ext_skull(volume<float> & output_inskull, volume<float> & output_outskull, volume<float> & output_outskin, const volume<float> & t1, const Mesh & m, const trMatrix & M) {
int glob_counter = 0;
int rem_counter = 0;
const double xdim = t1.xdim();
const double ydim = t1.ydim();
const double zdim = t1.zdim();
double imax = t1.max();
if (imax == 0) imax = 1;
volume<short> meshimage;
copyconvert(t1, meshimage);
meshimage = 0;
draw_mesh(meshimage, m);
for (vector<Mpoint*>::const_iterator i = m._points.begin(); i != m._points.end(); i++)
{
(*i)->data.clear();
double max_neighbour = 0;
const Vec normal = (*i)->local_normal();
const Vec n = Vec(normal.X/xdim, normal.Y/ydim, normal.Z/zdim);
for (list<Mpoint*>::const_iterator nei = (*i)->_neighbours.begin(); nei != (*i)->_neighbours.end(); nei++)
max_neighbour = Max(((**i) - (**nei)).norm(), max_neighbour);
max_neighbour = ceil((max_neighbour)/2);
const Pt mpoint((*i)->get_coord().X/xdim,(*i)->get_coord().Y/ydim,(*i)->get_coord().Z/zdim);
for (int ck = (int)floor(mpoint.Z - max_neighbour/zdim); ck <= (int)floor(mpoint.Z + max_neighbour/zdim); ck++)
for (int cj = (int)floor(mpoint.Y - max_neighbour/ydim); cj <= (int)floor(mpoint.Y + max_neighbour/ydim); cj++)
for (int ci = (int)floor(mpoint.X - max_neighbour/xdim); ci <= (int)floor(mpoint.X + max_neighbour/xdim); ci++)
{
bool compute = false;
const Pt point(ci, cj, ck);
const Pt realpoint(ci*xdim, cj*ydim, ck*zdim);
if (meshimage(ci, cj, ck) == 1)
{
double mindist = 10000;
for (list<Mpoint*>::const_iterator nei = (*i)->_neighbours.begin(); nei != (*i)->_neighbours.end(); nei++)
mindist = Min(((realpoint) - (**nei)).norm(), mindist);
if (mindist >= ((realpoint) - (**i)).norm()) compute = true;
}
if (compute)
{
glob_counter ++;
vector<double> val;
if (!special_case(realpoint, normal, M))
val = t1only_co_ext(t1, point, n);
else
{
val = t1only_special_extract(t1, point, n);
}
if (val.size() == 3)
{
Pt opoint(point.X, point.Y, point.Z);
Vec on(n.X, n.Y, n.Z);
Pt c0 = opoint + val[0]*on;
Pt c1 = opoint + val[1]*on;
Pt c2 = opoint + val[2]*on;
output_inskull((int)floor(c0.X + .5) + infxm,(int) floor(c0.Y + .5) + infym,(int) floor(c0.Z + .5) + infzm) +=1;
output_outskull((int)floor(c1.X + .5) + infxm,(int) floor(c1.Y + .5) + infym,(int) floor(c1.Z + .5) + infzm)+=1;
output_outskin((int)floor(c2.X + .5) + infxm,(int) floor(c2.Y + .5) + infym,(int) floor(c2.Z + .5) + infzm) +=1;
}
else {
rem_counter++;
if (val.size()==1)
{
Pt opoint(point.X, point.Y, point.Z);
Vec on(n.X, n.Y, n.Z);
Pt c0 = opoint + val[0]*on;
output_outskin((int)floor(c0.X + .5) + infxm,(int) floor(c0.Y + .5) + infym,(int) floor(c0.Z + .5) + infzm) +=1;
}
}
}
}
}
if (verbose.value())
{
cout<<" nb of profiles : "<<glob_counter<<endl;
cout<<" removed profiles : "<<100. * rem_counter/(double) glob_counter<<"%"<<endl;
}
}
示例3: adjust_initial_mesh
bet_parameters adjust_initial_mesh(const volume<float> & image, Mesh& m, const double & rad = 0., const double xpara=0., const double ypara=0., const double zpara=0.)
{
bet_parameters bp;
double xdim = image.xdim();
double ydim = image.ydim();
double zdim = image.zdim();
double t2, t98, t;
//computing t2 && t98
// cout<<"computing robust min && max begins"<<endl;
bp.min = image.min();
bp.max = image.max();
t2 = image.robustmin();
t98 = image.robustmax();
//t2=32.;
//t98=16121.;
// cout<<"computing robust min && max ends"<<endl;
t = t2 + .1*(t98 - t2);
bp.t98 = t98;
bp.t2 = t2;
bp.t = t;
// cout<<"t2 "<<t2<<" t98 "<<t98<<" t "<<t<<endl;
// cout<<"computing center && radius begins"<<endl;
//finds the COG
Pt center(0, 0, 0);
double counter = 0;
if (xpara == 0. & ypara==0. & zpara==0.)
{
double tmp = t - t2;
for (int k=0; k<image.zsize(); k++)
for (int j=0; j<image.ysize(); j++)
for (int i=0; i<image.xsize(); i++)
{
double c = image(i, j, k ) - t2;
if (c > tmp)
{
c = min(c, t98 - t2);
counter+=c;
center += Pt(c*i*xdim, c*j*ydim, c*k*zdim);
}
}
center=Pt(center.X/counter, center.Y/counter, center.Z/counter);
//cout<<counter<<endl;
// cout<<"cog "<<center.X<<" "<<center.Y<<" "<<center.Z<<endl;
}
else center=Pt(xpara, ypara, zpara);
bp.cog = center;
if (rad == 0.)
{
double radius=0;
counter=0;
double scale=xdim*ydim*zdim;
for (int k=0; k<image.zsize(); k++)
for (int j=0; j<image.ysize(); j++)
for (int i=0; i<image.xsize(); i++)
{
double c = image(i, j, k);
if (c > t)
{
counter+=1;
}
}
radius = pow (.75 * counter*scale/M_PI, 1.0/3.0);
// cout<<radius<<endl;
bp.radius = radius;
}
else (bp.radius = rad);
m.translation(center.X, center.Y, center.Z);
m.rescale (bp.radius/2, center);
// cout<<"computing center && radius ends"<<endl;
//computing tm
// cout<<"computing tm begins"<<endl;
vector<double> vm;
for (int k=0; k<image.zsize(); k++)
for (int j=0; j<image.ysize(); j++)
for (int i=0; i<image.xsize(); i++)
{
double d = image.value(i, j, k);
Pt p(i*xdim, j*ydim, k*zdim);
if (d > t2 && d < t98 && ((p - center)|(p - center)) < bp.radius * bp.radius)
vm.push_back(d);
}
int med = (int) floor(vm.size()/2.);
// cout<<"before sort"<<endl;
nth_element(vm.begin(), vm.begin() + med - 1, vm.end());
//partial_sort(vm.begin(), vm.begin() + med + 1, vm.end());
//double tm = vm[med];
double tm=(*max_element(vm.begin(), vm.begin() + med));
//.........这里部分代码省略.........