From 739c6854d5617e34fe5f696b14e862566e1249f5 Mon Sep 17 00:00:00 2001 From: John Lindsay Date: Tue, 13 Sep 2022 10:50:06 -0400 Subject: [PATCH] Fixes #278 This fixes an issue with RGB interpolation using the NN and IDW lidar interpolators (#278). --- .../tools/lidar_analysis/lidar_idw_interpolation.rs | 6 +++--- .../src/tools/lidar_analysis/lidar_nn_gridding.rs | 12 ++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/whitebox-tools-app/src/tools/lidar_analysis/lidar_idw_interpolation.rs b/whitebox-tools-app/src/tools/lidar_analysis/lidar_idw_interpolation.rs index 76511e72..bb9e78a2 100755 --- a/whitebox-tools-app/src/tools/lidar_analysis/lidar_idw_interpolation.rs +++ b/whitebox-tools-app/src/tools/lidar_analysis/lidar_idw_interpolation.rs @@ -816,9 +816,9 @@ impl WhiteboxTool for LidarIdwInterpolation { p.x, p.y, ((255u32 << 24) - | ((clr.blue as u32) << 16) - | ((clr.green as u32) << 8) - | (clr.red as u32)) + | (((clr.blue / 256) as u32) << 16) + | (((clr.green / 256) as u32) << 8) + | ((clr.red / 256) as u32)) as f64, ); } diff --git a/whitebox-tools-app/src/tools/lidar_analysis/lidar_nn_gridding.rs b/whitebox-tools-app/src/tools/lidar_analysis/lidar_nn_gridding.rs index eb4b2372..fc407fd9 100755 --- a/whitebox-tools-app/src/tools/lidar_analysis/lidar_nn_gridding.rs +++ b/whitebox-tools-app/src/tools/lidar_analysis/lidar_nn_gridding.rs @@ -782,9 +782,9 @@ impl WhiteboxTool for LidarNearestNeighbourGridding { p.x, p.y, ((255u32 << 24) - | ((clr.blue as u32) << 16) - | ((clr.green as u32) << 8) - | (clr.red as u32)) + | (((clr.blue / 256) as u32) << 16) + | (((clr.green / 256) as u32) << 8) + | ((clr.red / 256) as u32)) as f64, ); } @@ -860,7 +860,11 @@ impl WhiteboxTool for LidarNearestNeighbourGridding { configs.resolution_y = grid_res; configs.nodata = nodata; configs.data_type = DataType::F32; - configs.photometric_interp = PhotometricInterpretation::Continuous; + if interp_parameter != "rgb" { + configs.photometric_interp = PhotometricInterpretation::Continuous; + } else { + configs.photometric_interp = PhotometricInterpretation::RGB; + } configs.palette = palette.clone(); let mut output = Raster::initialize_using_config(&output_file, &configs);