def test_rand(self):
     """ Test rand. """
     img = CImg((100, 100))
     img.rand(-2, 2)
     val_min, val_max = img.min_max()
     self.assertGreaterEqual(val_min, -2)
     self.assertLessEqual(val_max, +2)
 def test_cut(self):
     """ Test cut. """
     img = CImg((100, 100))
     img.rand(-10, 10)
     img.cut(0, 1)
     max_val, min_val = img.max_min()
     self.assertEqual(max_val, 1)
     self.assertEqual(min_val, 0)
 def test_normalize(self):
     """ Test normalize. """
     img = CImg((10, 10))
     img.rand(-10, 10)
     img.normalize(-5, 5)
     min_val, max_val = img.min_max()
     self.assertEqual(min_val, -5)
     self.assertEqual(max_val, 5)
Esempio n. 4
0
 def test_save_png(self):
     """ Test save png. """
     img = CImg((100, 100), dtype=cimg.uint8)
     img.rand(0, 255)
     filename = self._get_testfilename() + '.png'
     img.save_png(filename)
     self.assertTrue(os.path.isfile(filename))
     os.remove(filename)
Esempio n. 5
0
 def test_save_tiff(self):
     """ Test save tiff. """
     img = CImg((100, 100), dtype=cimg.uint8)
     img.rand(0, 255)
     filename = self._get_testfilename() + '.tiff'
     img.save_tiff(filename,
                   compression_type=cimg.C_LZW,
                   voxel_size=0,
                   description="Test tiff")
     self.assertTrue(os.path.isfile(filename))
     os.remove(filename)