本文整理汇总了C++中volmagick::Volume::map方法的典型用法代码示例。如果您正苦于以下问题:C++ Volume::map方法的具体用法?C++ Volume::map怎么用?C++ Volume::map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类volmagick::Volume
的用法示例。
在下文中一共展示了Volume::map方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
#if 0
if(argc > 2)
{
VolMagick::Volume vol;
readVolumeFile(vol,argv[1]);
vol.min(volinfo.min());
vol.max(volinfo.max());
//vol.map(0.0,255.0);
//vol.voxelType(VolMagick::UChar);
vol.resize(VolMagick::Dimension(512,512,512));
writeVolumeFile(vol,argv[2]);
}
#endif
#if 0
if(argc > 2)
{
double realmin, realmax;
VolMagick::Volume vol;
std::vector<VolMagick::VolumeFileInfo> volinfos(argc-2);
volinfos[0].read(argv[1]);
realmin = volinfos[0].min();
realmax = volinfos[0].max();
for(unsigned int i=0; i<argc-2; i++)
{
volinfos[i].read(argv[i+1]);
if(realmin > volinfos[i].min()) realmin = volinfos[i].min();
if(realmax < volinfos[i].max()) realmax = volinfos[i].max();
}
cout << "Realmin: " << realmin << endl;
cout << "Realmax: " << realmax << endl;
createVolumeFile(argv[argc-1],
volinfo.boundingBox(),
volinfo.dimension(),
std::vector<VolMagick::VoxelType>(1, VolMagick::UChar),
1, argc-2,
0.0, double(argc-3));
for(unsigned int i=0; i<argc-2; i++)
{
readVolumeFile(vol,argv[i+1]);
//so the mapping is correct across all timesteps, we must set the real min and max across time
vol.min(realmin);
vol.max(realmax);
vol.map(0.0,255.0);
vol.voxelType(VolMagick::UChar);
writeVolumeFile(vol,argv[argc-1],0,i);
}
}
#endif
//vector test
#if 0
std::vector<VolMagick::Volume> vols(4);
{
char filename[256];
cout << "Testing RawV!" << endl;
vols[0].voxelType(VolMagick::UChar);
vols[0].desc("red");
vols[0].fill(130.0);
vols[1].voxelType(VolMagick::UChar);
vols[1].desc("green");
vols[1].fill(20.0);
vols[2].voxelType(VolMagick::UChar);
vols[2].desc("blue");
vols[2].fill(200.0);
vols[3].voxelType(VolMagick::Float);
vols[3].desc("alpha");
for(unsigned int k=0; k<vols[3].ZDim(); k++)
for(unsigned int j=0; j<vols[3].YDim(); j++)
for(unsigned int i=0; i<vols[3].XDim(); i++)
vols[3](i,j,k,
sqrt(float((i - (vols[3].XDim()/2.0))*(i - (vols[3].XDim()/2.0)) +
(j - (vols[3].YDim()/2.0))*(j - (vols[3].YDim()/2.0)) +
(k - (vols[3].ZDim()/2.0))*(k - (vols[3].ZDim()/2.0)))));
VolMagick::writeVolumeFile(vols,"test.rawv");
}
#endif
//cout << "std::streamoff size: " << sizeof(std::streamoff) << endl;
//ifstream test("flkajlff");
}
catch(VolMagick::Exception &e)
{
cerr << e.what() << endl;
}
catch(std::exception &e)
{
cerr << e.what() << endl;
}
return 0;
}
示例2: main
int main(int argc, char **argv)
{
if(argc < 3)
{
cerr << "Usage: " << argv[0] << " <volume file> <volume file>" << endl;
return 1;
}
try
{
VolMagickOpStatus status;
VolMagick::setDefaultMessenger(&status);
#if 0
double realmin, realmax;
VolMagick::Volume vol;
std::vector<VolMagick::VolumeFileInfo> volinfos(argc-2);
volinfos[0].read(argv[1]);
realmin = volinfos[0].min();
realmax = volinfos[0].max();
for(unsigned int i=0; i<argc-2; i++)
{
volinfos[i].read(argv[i+1]);
if(realmin > volinfos[i].min()) realmin = volinfos[i].min();
if(realmax < volinfos[i].max()) realmax = volinfos[i].max();
}
cout << "Realmin: " << realmin << endl;
cout << "Realmax: " << realmax << endl;
createVolumeFile(argv[argc-1],
volinfos[0].boundingBox(),
volinfos[0].dimension(),
std::vector<VolMagick::VoxelType>(1, VolMagick::UChar),
1, argc-2,
0.0, double(argc-3));
for(unsigned int i=0; i<argc-2; i++)
{
readVolumeFile(vol,argv[i+1]);
//so the mapping is correct across all timesteps, we must set the real min and max across time
vol.min(realmin);
vol.max(realmax);
vol.map(0.0,255.0);
vol.voxelType(VolMagick::UChar);
writeVolumeFile(vol,argv[argc-1],0,i);
}
#endif
const double errThresh = 0.01;
VolMagick::Volume vols[2];
VolMagick::readVolumeFile(vols[0],argv[1]);
VolMagick::readVolumeFile(vols[1],argv[2]);
if(vols[0].dimension() != vols[1].dimension()) throw VolMagick::VolumePropertiesMismatch("Volumes differ in dimension");
if(vols[0].boundingBox() != vols[1].boundingBox()) throw VolMagick::VolumePropertiesMismatch("Volumes differ in bounding box");
if(fabs(vols[0].min() - vols[1].min()) > errThresh) throw VolMagick::VolumePropertiesMismatch("Minimum voxel values differ");
if(fabs(vols[0].max() - vols[1].max()) > errThresh) throw VolMagick::VolumePropertiesMismatch("Maximum voxel values differ");
for(VolMagick::uint64 i = 0; i<vols[0].dimension().size(); i++)
if(fabs(vols[0](i) - vols[1](i)) > errThresh) throw VolMagick::VolumePropertiesMismatch("Voxel values differ");
}
catch(VolMagick::Exception &e)
{
cerr << e.what() << endl;
}
catch(std::exception &e)
{
cerr << e.what() << endl;
}
return 0;
}