Пример #1
0
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);
}
Пример #2
0
 void PairWiseDrawer::drawFeature(int i, const OERegion& f, const Color3ub& c) const
 {
   assert(i == 0 || i == 1);
   f.draw(c, z1, offF(i));
 }