本文整理汇总了C++中array::T方法的典型用法代码示例。如果您正苦于以下问题:C++ array::T方法的具体用法?C++ array::T怎么用?C++ array::T使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类array
的用法示例。
在下文中一共展示了array::T方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: emboss
/**
* azimuth range is [0-360]
* elevation range is [0-180]
* depth range is [1-100]
* Note: this function has been tailored after
* the emboss implementation in GIMP editor
**/
array emboss(const array &input, float azimuth, float elevation, float depth)
{
if (depth<1 || depth>100) {
printf("Depth should be in the range of 1-100");
return input;
}
static float x[3] = { -1, 0, 1 };
static array hg(3, x);
static array vg = hg.T();
array in = input;
if (in.dims(2)>1)
in = colorSpace(input, AF_GRAY, AF_RGB);
else
in = input;
// convert angles to radians
float phi = elevation*af::Pi / 180.0f;
float theta = azimuth*af::Pi / 180.0f;
// compute light pos in cartesian coordinates
// and scale with maximum intensity
// phi will effect the amount of we intend to put
// on a pixel
float pos[3];
pos[0] = 255.99f * cos(phi)*cos(theta);
pos[1] = 255.99f * cos(phi)*sin(theta);
pos[2] = 255.99f * sin(phi);
// compute gradient vector
array gx = convolve(in, vg);
array gy = convolve(in, hg);
float pxlz = (6 * 255.0f) / depth;
array zdepth = constant(pxlz, gx.dims());
array vdot = gx*pos[0] + gy*pos[1] + pxlz*pos[2];
array outwd = vdot < 0.0f;
array norm = vdot / sqrt(gx*gx + gy*gy + zdepth*zdepth);
array color = outwd * 0.0f + (1 - outwd) * norm;
return color;
}