Exemplo n.º 1
0
//--------------------------------------------------------------
ofVec3f tensor_to_pixel_dims(const tensorflow::Tensor &t, string chmap) {
    int rank = t.shape().dims();
    vector<int> tensor_dims(rank);
    for(int i=0; i<rank; i++) tensor_dims[i] = t.dim_size(i); // useful for debugging

    // add z to end of string to top it up to length 3, this'll make it default to 1
    while(chmap.length()<3) chmap += "z";

    // which tensor dimension to use for which image xyz component
    // initially read from chmap parameter
    ofVec3f dim_indices(chmap[0]-'0', chmap[1]-'0', chmap[2]-'0');

    // if tensor rank is less than the chmap, adjust dim_indices accordingly (
    if(rank < chmap.length()) {
        if(rank == 1) {
            //  if(dim_indices)
            dim_indices.set(0, 99, 99);   // set these large so they default to 1
        } else if(rank == 2) {
            if(dim_indices[1] > dim_indices[0]) dim_indices.set(0, 1, 99);
            else dim_indices.set(1, 0, 99);
        }
    }

    ofVec3f image_dims (
                (rank > dim_indices[0] ? t.dim_size( dim_indices[0]) : 1),
        (rank > dim_indices[1] ? t.dim_size( dim_indices[1]) : 1),
        (rank > dim_indices[2] ? t.dim_size( dim_indices[2]) : 1)
      );
    return image_dims;
}
Exemplo n.º 2
0
InputParameters validParams<FunctionGradAux>()
{
  InputParameters params = validParams<AuxKernel>();
  MooseEnum dim_indices("x=0 y=1 z=2", "x");
  params.addRequiredParam<FunctionName>("function", "Function used to compute gradient");
  params.addParam<MooseEnum>("dimension_index", dim_indices, "The dimension index x|y|z");
  return params;
}