1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 03:35:53 +01:00

Make the DEM data borders look much better

This commit is contained in:
Martin Tůma 2024-05-21 20:59:06 +02:00
parent da2b6661f6
commit 27401d58b7

View File

@ -99,16 +99,31 @@ MatrixD Filter::blur(const MatrixD &m, int radius)
{ {
MatrixD src(m); MatrixD src(m);
MatrixD dst(m.h(), m.w()); MatrixD dst(m.h(), m.w());
double sum = 0;
int cnt = 0;
for (int i = 0; i < m.size(); i++) for (int i = 0; i < m.size(); i++) {
if (std::isnan(m.at(i))) if (!std::isnan(m.at(i))) {
src.at(i) = -500; sum += m.at(i);
cnt++;
}
}
if (cnt != m.size()) {
double avg = sum / cnt;
for (int i = 0; i < m.size(); i++)
if (std::isnan(m.at(i)))
src.at(i) = avg;
}
gaussBlur4(src, dst, radius); gaussBlur4(src, dst, radius);
for (int i = 0; i < dst.size(); i++) if (cnt != m.size()) {
if (std::isnan(m.at(i))) for (int i = 0; i < dst.size(); i++)
dst.at(i) = NAN; if (std::isnan(m.at(i)))
dst.at(i) = NAN;
}
return dst; return dst;
} }