4 #include <stb_image_write.h>
10 #include <type_traits>
20 using DScalar =
DScalar2<double, Eigen::Matrix<double, -1, 1>, Eigen::Matrix<double, -1, -1>>;
22 Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor | Eigen::AutoAlign>;
31 Image(
int height_,
int width_) {
m_image.resize(height_, width_); };
42 std::decay_t<T>
get(
const T& u,
const T& v)
const;
44 std::pair<int, int>
get_pixel_index(
const double& u,
const double& v)
const;
49 const std::function<
float(
const double&,
const double&)>& f,
52 bool set(
const int r,
const int c,
const float v)
57 bool save(
const std::filesystem::path& path)
const;
76 auto size = std::max(w, h);
78 auto x = u *
static_cast<std::decay_t<T>
>(size);
79 auto y = v *
static_cast<std::decay_t<T>
>(size);
83 static_cast<size_t>(w),
84 static_cast<size_t>(h),
98 std::array<Image, 3>
load_rgb_image(
const std::filesystem::path& path);
101 double normalization_scale,
102 const Eigen::Matrix<double, 1, 3>& offset,
103 const std::filesystem::path& position_path,
104 const std::filesystem::path& normal_path,
105 const std::filesystem::path& texture_path,
106 float min_height = 0.f,
107 float max_height = 1.f);
int get_coordinate(const int x, const WrappingMode mode) const
Image down_sample() const
Eigen::Matrix< float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor|Eigen::AutoAlign > ImageMatrixf
WrappingMode get_wrapping_mode_x() const
const ImageMatrixf & get_raw_image() const
WrappingMode get_wrapping_mode_y() const
std::decay_t< T > get(const T &u, const T &v) const
void load(const std::filesystem::path &path, WrappingMode mode_x, WrappingMode mode_y)
ImageMatrixf & ref_raw_image()
void set_wrapping_mode(WrappingMode mode_x, WrappingMode mode_y)
Image(int height_, int width_)
std::pair< int, int > get_pixel_index(const double &u, const double &v) const
bool save(const std::filesystem::path &path) const
bool set(const int r, const int c, const float v)
float get_pixel(const int i, const int j) const
bool set(const std::function< float(const double &, const double &)> &f, const WrappingMode mode_x=WrappingMode::CLAMP_TO_EDGE, const WrappingMode mode_y=WrappingMode::CLAMP_TO_EDGE)
std::array< Image, 3 > load_rgb_image(const std::filesystem::path &path)
std::array< Image, 3 > combine_position_normal_texture(double normalization_scale, const Eigen::Matrix< double, 1, 3 > &offset, const std::filesystem::path &position_path, const std::filesystem::path &normal_path, const std::filesystem::path &height_path, float min_height, float max_height)
const BicubicMatrix & get_bicubic_matrix()
std::decay_t< T > eval_bicubic_coeffs(const BicubicVector< float > &coeffs, const T &sx, const T &sy)
Image buffer_to_image(const std::vector< float > &buffer, int w, int h)
Eigen::Matrix< T, 16, 1 > BicubicVector
double get_value(float x)
BicubicVector< float > extract_samples(const size_t width, const size_t height, const float *buffer, const double sx_, const double sy_, const WrappingMode mode_x, const WrappingMode mode_y)
void split_and_save_3channels(const std::filesystem::path &path)
Automatic differentiation scalar with first- and second-order derivatives.