45 :
Mat<
float>(mat.GetWidth(), mat.GetHeight(), mat.GetDepth()) {
55 const size_t new_width = std::round(
width_ * factor);
56 const size_t new_height = std::round(
height_ * factor);
57 std::vector<float> new_data(new_width * new_height * 3);
60 for (
size_t d = 0; d < 3; ++d) {
62 const size_t new_offset = d * new_width * new_height;
64 new_width, new_data.data() + new_offset);
71 data_.shrink_to_fit();
74 for (
size_t r = 0; r <
height_; ++r) {
75 for (
size_t c = 0; c <
width_; ++c) {
77 const float squared_norm =
normal.squaredNorm();
78 if (squared_norm > 0) {
79 normal /= std::sqrt(squared_norm);
92 const float factor_x =
static_cast<float>(max_width) /
width_;
93 const float factor_y =
static_cast<float>(max_height) /
height_;
94 Rescale(std::min(factor_x, factor_y));
111 127.5f * (-
normal[1] + 1),
bool SetPixel(const int x, const int y, const BitmapColor< uint8_t > &color)
bool Allocate(const int width, const int height, const bool as_rgb)
std::vector< float > data_
void Set(const size_t row, const size_t col, const float value)
float Get(const size_t row, const size_t col, const size_t slice=0) const
void GetSlice(const size_t row, const size_t col, float *values) const
const std::vector< T > & GetData() const
void Rescale(const float factor)
void Downsize(const size_t max_width, const size_t max_height)
void DownsampleImage(const float *data, const int rows, const int cols, const int new_rows, const int new_cols, float *downsampled)