MCPcopy Create free account
hub / github.com/colmap/colmap / ToBitmap

Method ToBitmap

src/colmap/mvs/normal_map.cc:99–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99Bitmap NormalMap::ToBitmap() const {
100 THROW_CHECK_GT(width_, 0);
101 THROW_CHECK_GT(height_, 0);
102 THROW_CHECK_EQ(depth_, 3);
103
104 Bitmap bitmap(width_, height_, true);
105
106 for (size_t y = 0; y < height_; ++y) {
107 for (size_t x = 0; x < width_; ++x) {
108 float normal[3] = {0};
109 GetSlice(y, x, normal);
110 if (normal[0] != 0 || normal[1] != 0 || normal[2] != 0) {
111 const BitmapColor<float> color(127.5f * (-normal[0] + 1),
112 127.5f * (-normal[1] + 1),
113 -255.0f * normal[2]);
114 bitmap.SetPixel(x, y, color.Cast<uint8_t>());
115 } else {
116 bitmap.SetPixel(x, y, BitmapColor<uint8_t>(0));
117 }
118 }
119 }
120
121 return bitmap;
122}
123
124} // namespace mvs
125} // namespace colmap

Callers

nothing calls this directly

Calls 1

SetPixelMethod · 0.80

Tested by

no test coverage detected