void check_affine_adaptation(const Image<unsigned char>& image, const OERegion& f) { const auto w = image.width(); const auto h = image.height(); const auto r = 100.f; const auto patch_sz = 2*r; auto gray32f_image = image.convert<float>(); auto patch = Image<float>{ w, h }; patch.array().fill(0.f); display(image); f.draw(Blue8); auto region = OERegion{ f }; region.center().fill(patch_sz/2.f); region.orientation() = 0.f; region.shape_matrix() = Matrix2f::Identity()*4.f / (r*r); auto A = f.affinity(); cout << "A=\n" << A << endl; for (int y = 0; y < patch_sz; ++y) { auto v = float{ 2 * (y - r) / r }; for (int x = 0; x < patch_sz; ++x) { auto u = float{ 2 * (x - r) / r }; Point3f P{ A * Point3f{ u, v, 1. } }; Point2d p{ P.head(2).cast<double>() }; if (p.x() < 0 || p.x() >= w || p.y() < 0 || p.y() >= h) continue; patch(x,y) = static_cast<float>(interpolate(gray32f_image, p)); } } auto w1 = active_window(); auto w2 = create_window(static_cast<int>(patch_sz), static_cast<int>(patch_sz)); set_active_window(w2); set_antialiasing(); display(patch); region.draw(Blue8); millisleep(1000); close_window(w2); millisleep(40); set_active_window(w1); }
bool KeyProximity::operator()(const OERegion& f1, const OERegion& f2) const { SquaredRefDistance<float, 2> m1(mappedSquaredMetric(f1)); SquaredRefDistance<float, 2> m2(mappedSquaredMetric(f1)); float sd1 = m1(f1.center(), f2.center()); float sd2 = m2(f1.center(), f2.center()); float pixelDist2 = (f1.center() - f2.center()).squaredNorm(); return (pixelDist2 < sqPixDist) || (sd1 < sqMetricDist) || (sd2 < sqMetricDist); }
std::vector<float> ComputeDominantOrientations:: operator()(const ImagePyramid<Vector2f>& pyramid, const OERegion& extremum, const Point2i& scale_octave_pair) const { const auto& s_index = scale_octave_pair(0); const auto& o_index = scale_octave_pair(1); auto x = extremum.x(); auto y = extremum.y(); auto s = pyramid.scale_relative_to_octave(s_index); return this->operator()(pyramid(s_index, o_index), x, y, s); }
//! Helper member function. SIFTDescriptor operator()(const OERegion& f, const Image<Vector2f>& gradPolar) const { return this->operator()(f.x(), f.y(), f.scale(), f.orientation(), gradPolar); }
//! Helper member function. descriptor_type operator()(const OERegion& f, const Image<Vector2f>& grad_polar_coords) const { return this->operator()(f.x(), f.y(), f.scale(), f.orientation(), grad_polar_coords); }
SquaredRefDistance<float, 2> mappedSquaredMetric(const OERegion& f) const { return SquaredRefDistance<float, 2>(f.shapeMat()); }
void PairWiseDrawer::drawFeature(int i, const OERegion& f, const Color3ub& c) const { assert(i == 0 || i == 1); f.draw(c, z1, offF(i)); }