Ejemplo n.º 1
0
TEST(ReadPng, Png_Monochrome) {
  Image<unsigned char> image;
  string png_filename = FBLIB_GLOBAL_SRC_DIR + "/data/image_test/two_pixels_monochrome.png";
  EXPECT_TRUE(ReadImage(png_filename.c_str(), &image));
  EXPECT_EQ(2, image.Width());
  EXPECT_EQ(1, image.Height());
  EXPECT_EQ(1, image.Channels());
  EXPECT_EQ(image(0,0), (unsigned char)255);
  EXPECT_EQ(image(0,1), (unsigned char)0);
}
Ejemplo n.º 2
0
TEST(ReadJpg, Jpg_Color) {
  Image<RGBColor> image;
  string jpg_filename = FBLIB_GLOBAL_SRC_DIR + "/data/image_test/two_pixels_color.jpg";
  EXPECT_TRUE(ReadImage(jpg_filename.c_str(), &image));
  EXPECT_EQ(2, image.Width());
  EXPECT_EQ(1, image.Height());
  EXPECT_EQ(3, image.Channels());
  EXPECT_EQ(image(0,0), RGBColor(255, 125, 11));
  EXPECT_EQ(image(0,1), RGBColor( 20, 127, 255));
}
Ejemplo n.º 3
0
TEST(ReadPnm, Ppm) {
  Image<RGBColor> image;
  string ppm_filename = FBLIB_GLOBAL_SRC_DIR + "/data/image_test/two_pixels.ppm";
  EXPECT_TRUE(ReadImage(ppm_filename.c_str(), &image));
  EXPECT_EQ(2, image.Width());
  EXPECT_EQ(1, image.Height());
  EXPECT_EQ(3, image.Channels());
  EXPECT_EQ(image(0,0), RGBColor( (unsigned char)255));
  EXPECT_EQ(image(0,1), RGBColor( (unsigned char)0));
}
Ejemplo n.º 4
0
TEST(ReadPnm, PgmComments) {
  Image<unsigned char> image;
  string pgm_filename = FBLIB_GLOBAL_SRC_DIR + "/data/image_test/two_pixels_gray.pgm";
  EXPECT_TRUE(ReadImage(pgm_filename.c_str(), &image));
  EXPECT_EQ(2, image.Width());
  EXPECT_EQ(1, image.Height());
  EXPECT_EQ(1, image.Channels());
  EXPECT_EQ(image(0,0), (unsigned char)255);
  EXPECT_EQ(image(0,1), (unsigned char)0);
}
Ejemplo n.º 5
0
TEST(ReadPng, Png_Color) {
  Image<RGBAColor> image;
  string png_filename = FBLIB_GLOBAL_SRC_DIR + "/data/image_test/two_pixels_color.png";
  EXPECT_TRUE(ReadImage(png_filename.c_str(), &image));
  // Channels is 4 (RGBA by default)
  EXPECT_EQ(2, image.Width());
  EXPECT_EQ(1, image.Height());
  EXPECT_EQ(4, image.Channels());
  EXPECT_EQ(image(0,0), RGBAColor(255, 125, 10, 255));
  EXPECT_EQ(image(0,1), RGBAColor( 20, 127, 255,255));
}
Ejemplo n.º 6
0
bool WriteRGBLDR(const Image<unsigned char, 3>& out,
    const std::string& image_file_out) {
  try {
	  IplImage * image = cvCreateImage(cvSize(out.Width(), out.Height()), 32, out.Channels());
	  CvScalar s;
    for (int x = 0; x < out.Width(); ++x) {
      for (int y = 0; y < out.Height(); ++y) {
		  s.val[0] = out.GetPixelComponent(x, y, 2);
		  s.val[1] = out.GetPixelComponent(x, y, 1);
		  s.val[2] = out.GetPixelComponent(x, y, 0);
		  cvSet2D(image, y, x, s);
      }
    }
	return cvSaveImage(image_file_out.c_str(), image);
  } catch (std::exception& ex) {
    return false;
  }
}