Skip to content

Commit

Permalink
Fix colors in the X-ray points processor. (cartographer-project#460)
Browse files Browse the repository at this point in the history
mean_..._in_column was broken in cartographer-project#423.
  • Loading branch information
wohe committed Aug 17, 2017
1 parent 9498cc9 commit c29fec3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
24 changes: 8 additions & 16 deletions cartographer/io/xray_points_processor.cc
Expand Up @@ -35,15 +35,15 @@ namespace {

struct PixelData {
size_t num_occupied_cells_in_column = 0;
double mean_r = 0.;
double mean_g = 0.;
double mean_b = 0.;
float mean_r = 0.;
float mean_g = 0.;
float mean_b = 0.;
};

using PixelDataMatrix =
Eigen::Matrix<PixelData, Eigen::Dynamic, Eigen::Dynamic>;

double Mix(const double a, const double b, const double t) {
float Mix(const float a, const float b, const float t) {
return a * (1. - t) + t * b;
}

Expand Down Expand Up @@ -74,18 +74,10 @@ Image IntoImage(const PixelDataMatrix& mat) {
// details like chairs and tables are still well visible.
const float saturation =
std::log(cell.num_occupied_cells_in_column) / max;
double mean_r_in_column = (cell.mean_r / 255.);
double mean_g_in_column = (cell.mean_g / 255.);
double mean_b_in_column = (cell.mean_b / 255.);

double mix_r = Mix(1., mean_r_in_column, saturation);
double mix_g = Mix(1., mean_g_in_column, saturation);
double mix_b = Mix(1., mean_b_in_column, saturation);

image.SetPixel(
x, y,
{{FloatComponentToUint8(mix_r), FloatComponentToUint8(mix_g),
FloatComponentToUint8(mix_b)}});
const FloatColor color = {{Mix(1.f, cell.mean_r, saturation),
Mix(1.f, cell.mean_g, saturation),
Mix(1.f, cell.mean_b, saturation)}};
image.SetPixel(x, y, ToUint8Color(color));
}
}
return image;
Expand Down
6 changes: 3 additions & 3 deletions cartographer/io/xray_points_processor.h
Expand Up @@ -58,9 +58,9 @@ class XRayPointsProcessor : public PointsProcessor {

private:
struct ColumnData {
double sum_r = 0.;
double sum_g = 0.;
double sum_b = 0.;
float sum_r = 0.;
float sum_g = 0.;
float sum_b = 0.;
uint32_t count = 0;
};

Expand Down

0 comments on commit c29fec3

Please sign in to comment.