本文整理汇总了C++中Image2D::setValue方法的典型用法代码示例。如果您正苦于以下问题:C++ Image2D::setValue方法的具体用法?C++ Image2D::setValue怎么用?C++ Image2D::setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image2D
的用法示例。
在下文中一共展示了Image2D::setValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
string outputFilename = vm["output"].as<std::string>();
double lx, ly, lz, px, py, pz;
bool usingAllDirectionLightSource = false;
if(vm.count("lx") && vm.count("ly") && vm.count("lz"))
{
lx = vm["lx"].as<double>();
ly = vm["ly"].as<double>();
lz = vm["lz"].as<double>();
}
else if(vm.count("px") && vm.count("py") && vm.count("pz"))
{
px = vm["px"].as<double>();
py = vm["py"].as<double>();
pz = vm["pz"].as<double>();
usingAllDirectionLightSource = true;
}
else if (!vm.count("reflectanceMap"))
{
trace.error() << "You need to specify either the light source direction or position (if you use a all directions model)." << std::endl;
exit(0);
}
LambertianShadindFunctor<Image2D, Z3i::RealPoint> lShade (Z3i::RealPoint(lx,ly,lz));
LambertianShadindFunctorAllDirections<Image2D, Z3i::RealPoint> lShadePosD (Z3i::RealPoint(px ,py, pz));
SpecularNayarShadindFunctor<Image2D, Z3i::RealPoint> lSpecular (Z3i::RealPoint(lx,ly,lz), 0, 0, 0);
SpecularNayarShadindFunctorAllDirections<Image2D, Z3i::RealPoint> lSpecularPosD (Z3i::RealPoint(px,py,pz), 0, 0, 0);
bool useSpecular = false;
if(vm.count("specularModel")){
std::vector<double> vectParam = vm["specularModel"].as<std::vector<double> > ();
if(vectParam.size() != 3)
{
trace.warning() << "You have not specify all specular parameters... using lambertian model instead." << std::endl;
}
else
{
useSpecular = true;
lSpecular.myKld = vectParam[0];
lSpecular.myKls = vectParam[1];
lSpecular.mySigma = vectParam[2];
lSpecularPosD.myKld = vectParam[0];
lSpecularPosD.myKls = vectParam[1];
lSpecularPosD.mySigma = vectParam[2];
if(vectParam[2]==0.0)
{
trace.error()<< "a 0 value for sigma is not possible in the Nayar model, please change it. "<< std::endl;
exit(1);
}
}
}
trace.info() << "Reading input file " << inputFilename ;
Image2D inputImage = DGtal::GenericReader<Image2D>::import(inputFilename);
Image2DNormals vectNormals (inputImage.domain());
Image2D result (inputImage.domain());
if(vm.count("importNormal")){
std::string normalFileName = vm["importNormal"].as<string>();
importNormals(normalFileName, vectNormals);
}else{
computerBasicNormalsFromHeightField(inputImage, vectNormals);
}
if(vm.count("reflectanceMap"))
{
ImageMapReflectance<Image2D, Z3i::RealPoint> lMap(vm["reflectanceMap"].as<std::string>());
for(typename Image2D::Domain::ConstIterator it = inputImage.domain().begin();
it != inputImage.domain().end(); it++){
if(vm.count("reflectanceMap"))
{
result.setValue(*it, lMap(vectNormals(*it)));
}
}
IdColor id;
PPMWriter<Image2D, IdColor >::exportPPM(outputFilename, result, id);
}
else
{
for(typename Image2D::Domain::ConstIterator it = inputImage.domain().begin();
it != inputImage.domain().end(); it++){
if(usingAllDirectionLightSource)
{
result.setValue(*it, useSpecular? lSpecularPosD(vectNormals(*it), *it, inputImage(*it)):
lShadePosD(vectNormals(*it), *it, inputImage(*it)));
}
else
{
result.setValue(*it, useSpecular? lSpecular(vectNormals(*it)):lShade(vectNormals(*it)));
}
}
result >> outputFilename;
}
return 0;
}