-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'vegetation-mix' into 'master'
Vegetation false positives reduction See merge request gislab/cloudtools!10
- Loading branch information
Showing
7 changed files
with
209 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include <vector> | ||
#include <cmath> | ||
#include <iostream> | ||
#include <CloudTools.DEM/SweepLineCalculation.hpp> | ||
#include <CloudTools.DEM/DatasetCalculation.hpp> | ||
|
||
|
||
namespace CloudTools::DEM | ||
{ | ||
/// <summary> | ||
/// Represents the removal of false positive seed points close to buildings | ||
/// </summary> | ||
template <typename DataType = float> | ||
class BuildingFacadeSeedRemoval : public DatasetCalculation<DataType> | ||
{ | ||
std::vector<OGRPoint> &seedPoints; | ||
public: | ||
int threshold; | ||
/// <summary> | ||
/// Initializes a new instance of the class. Loads input metadata and defines calculation. | ||
/// </summary> | ||
/// <param name="sourcePaths">The source files of the difference comparison.</param> | ||
/// <param name="progress">The callback method to report progress.</param> | ||
BuildingFacadeSeedRemoval(std::vector<OGRPoint>& seedPoints, | ||
const std::vector<std::string>& sourcePaths, | ||
Operation::ProgressType progress = nullptr, | ||
int threshold = 20) | ||
: DatasetCalculation<DataType>(sourcePaths, nullptr, progress), | ||
seedPoints(seedPoints), | ||
threshold(threshold) | ||
{ | ||
initialize(); | ||
} | ||
|
||
BuildingFacadeSeedRemoval(const BuildingFacadeSeedRemoval&) = delete; | ||
BuildingFacadeSeedRemoval& operator=(const BuildingFacadeSeedRemoval&) = delete; | ||
|
||
private: | ||
/// <summary> | ||
/// Initializes the new instance of the class. | ||
/// </summary> | ||
void initialize(); | ||
}; | ||
|
||
template <typename DataType> | ||
void BuildingFacadeSeedRemoval<DataType>::initialize() | ||
{ | ||
this->computation = [this](int x, int y) | ||
{ | ||
std::vector<int> idxs; | ||
int c = 0; | ||
for (auto& point: seedPoints) | ||
{ | ||
int counter = 0; | ||
int ws = 3; // window size = ws*2 + 1 | ||
int px = point.getX(); | ||
int py = point.getY(); | ||
for(int i = px - ws; i <= px + ws; i++){ | ||
for(int j = py - ws; j <= py + ws; j++){ | ||
if(!this->hasSourceData(0,i,j) && this->sourceData(1,i,j) > 10){ | ||
counter++; | ||
} | ||
} | ||
} | ||
if(counter > threshold){ | ||
idxs.push_back(c); | ||
} | ||
c++; | ||
} | ||
for (int i = idxs.size() - 1; i >= 0; --i) { | ||
seedPoints.erase(seedPoints.begin() + idxs[i]); | ||
} | ||
}; | ||
} | ||
} // CloudTools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include <vector> | ||
#include <cmath> | ||
#include <iostream> | ||
|
||
#include <CloudTools.DEM/SweepLineTransformation.hpp> | ||
|
||
namespace CloudTools | ||
{ | ||
namespace DEM | ||
{ | ||
/// <summary> | ||
/// Represents a DTM in which rivers are not nodata points, but instead have a constant value of -0.4 | ||
/// </summary> | ||
template <typename DataType = float> | ||
class RiverMask : public SweepLineTransformation<DataType> | ||
{ | ||
public: | ||
RiverMask(const std::vector<std::string>& sourcePaths, | ||
const std::string& targetPath, | ||
Operation::ProgressType progress = nullptr) | ||
: SweepLineTransformation<DataType>(sourcePaths, targetPath, nullptr, progress) | ||
{ | ||
initialize(); | ||
} | ||
|
||
RiverMask(const RiverMask&) = delete; | ||
RiverMask& operator=(const RiverMask&) = delete; | ||
|
||
private: | ||
/// <summary> | ||
/// Initializes the new instance of the class. | ||
/// </summary> | ||
void initialize(); | ||
/// <summary> | ||
/// Extremal low value for rivers. | ||
/// </summary> | ||
const int riverHeight = -1000; | ||
}; | ||
|
||
template <typename DataType> | ||
void RiverMask<DataType>::initialize() | ||
{ | ||
/// returns the DTM value, if both the DTM and the DSM value is given; | ||
/// returns -0.4 if only the DTM value or neither the DTM and the DSM value is given; | ||
/// return the DSM value, if only the DSM value is given. | ||
this->computation = [this](int x, int y, const std::vector<Window<DataType>>& sources) | ||
{ | ||
if (!sources[0].hasData() && sources[1].hasData()) | ||
return static_cast<DataType>(this->nodataValue); | ||
if (!sources[1].hasData()) | ||
return static_cast<DataType>(riverHeight); | ||
if (sources[0].hasData()) | ||
return static_cast<DataType>(sources[0].data()); | ||
}; | ||
} | ||
} // DEM | ||
} // CloudTools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters