MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / get_color

Method get_color

examples/pde/bhrt.cpp:857–882  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

855 Background(const af::array& image_) { image = image_; }
856
857 af::array get_color(const af::array& ray_dir) const {
858 auto spherical_dir = cart_to_sph_position(ray_dir);
859
860 auto img_height = image.dims()[0];
861 auto img_width = image.dims()[1];
862 auto count = ray_dir.dims()[1];
863
864 // Spherical mapping of the direction to a pixel of the image
865 af::array o = spherical_dir(1, af::span);
866 af::array p = spherical_dir(2, af::span);
867
868 auto x = (p / af::Pi + 1.0) * img_width / 2.0;
869 auto y = (o / af::Pi) * img_height;
870
871 // Interpolate the colors of the image from the calculated pixel
872 // positions
873 af::array colors = af::approx2(image, af::moddims(y.as(f32), count),
874 af::moddims(x.as(f32), count),
875 af::interpType::AF_INTERP_CUBIC_SPLINE);
876
877 // Zero out the color of any null rays
878 colors = af::moddims(colors, af::dim4(count, 3));
879 af::replace(colors, !af::isNaN(colors), 0.f);
880
881 return colors;
882 }
883};
884
885/**

Callers 1

generate_imageFunction · 0.45

Calls 8

cart_to_sph_positionFunction · 0.85
moddimsFunction · 0.85
isNaNFunction · 0.85
asMethod · 0.80
approx2Function · 0.50
dim4Class · 0.50
replaceFunction · 0.50
dimsMethod · 0.45

Tested by

no test coverage detected