0
OSRM-Projectで双線形補間について質問があります。 私は「通常の」双線形補間を理解しています。ここではウィキペディアからの映像は、非常識です:双線形補間 - OSRM Rastersource
今私は、ラスタソースデータ用OSRM・プロジェクトで使用されている双一次補間を理解しようとしています。コードがどのように動作するか
// Query raster source using bilinear interpolation
RasterDatum RasterSource::GetRasterInterpolate(const int lon, const int lat) const
{
if (lon < xmin || lon > xmax || lat < ymin || lat > ymax)
{
return {};
}
const auto xthP = (lon - xmin)/xstep;
const auto ythP =
(ymax - lat)/
ystep; // the raster texture uses a different coordinate system with y pointing downwards
const std::size_t top = static_cast<std::size_t>(fmax(floor(ythP), 0));
const std::size_t bottom = static_cast<std::size_t>(fmin(ceil(ythP), height - 1));
const std::size_t left = static_cast<std::size_t>(fmax(floor(xthP), 0));
const std::size_t right = static_cast<std::size_t>(fmin(ceil(xthP), width - 1));
// Calculate distances from corners for bilinear interpolation
const float fromLeft = xthP - left; // this is the fraction part of xthP
const float fromTop = ythP - top; // this is the fraction part of ythP
const float fromRight = 1 - fromLeft;
const float fromBottom = 1 - fromTop;
return {static_cast<std::int32_t>(raster_data(left, top) * (fromRight * fromBottom) +
raster_data(right, top) * (fromLeft * fromBottom) +
raster_data(left, bottom) * (fromRight * fromTop) +
raster_data(right, bottom) * (fromLeft * fromTop))};
}
は、誰かが私に説明できますか?
入力フォーマットは、ASCII形式のSRTMデータです。
変数高と幅がNROWSとncolumnsとして定義されます。
数が同様のXSTEP、最大と分ためYSTEPと幅ため高さあるreturn (max - min)/(static_cast<float>(count) - 1)
:XSTEPとYSTEPは次のように定義されている 変数。
その他の質問 TIF形式のデータに同じコードを使用できますか?
あなたが言うように、すでに双線形補間を理解しているなら、確かにこのコードの大部分を理解しているはずですか? – meowgoesthedog
さて、私は明らかにする必要があります:私は双線形補間の理論を理解しています。私はこのコードの基本的な論理を理解していますが、なぜ私は理解できません。変数 "bottom"が計算され、特に "height - 1"となります。そして、 "fromX"変数の計算はどのように機能しますか? –