public void TestAverageLumi() { HdrImage img = new HdrImage(2, 1); img.setPixel(0, 0, new Color(5.0f, 10.0f, 15.0f)); img.setPixel(1, 0, new Color(500.0f, 1000.0f, 1500.0f)); Assert.True(Utility.areClose(img.averageLumi(), 100.0f), "TestAverageLumi failed - Assert 1/1"); }
public void TestNormalizeImage() { var img = new HdrImage(2, 1); img.setPixel(0, 0, new Color(0.5e1f, 1.0e1f, 1.5e1f)); img.setPixel(1, 0, new Color(0.5e3f, 1.0e3f, 1.5e3f)); img.normalizeImage(factor: 1000.0f, luminosity: 100.0f); Assert.True(img.getPixel(0, 0).isClose(new Color(0.5e2f, 1.0e2f, 1.5e2f)), "TestNormalizeImage failed - Assert 1/2"); Assert.True(img.getPixel(1, 0).isClose(new Color(0.5e4f, 1.0e4f, 1.5e4f)), "TestNormalizeImage failed - Assert 2/2"); }
public void TestGetSetPixel() { var appo = new Color(5.0f, 6.0f, 7.0f); DummyImage.setPixel(3, 2, appo); Assert.True(DummyImage.getPixel(3, 2).isClose(appo), "TestGetSetPixel failed - Assert 1/1"); }
public void TestClampImage() { var img = new HdrImage(2, 1); img.setPixel(0, 0, new Color(0.5e1f, 1.0e1f, 1.5e1f)); img.setPixel(1, 0, new Color(0.5e3f, 1.0e3f, 1.5e3f)); img.clampImage(); foreach (var curPixel in img.pixel) { Assert.True((curPixel.r >= 0) && (curPixel.r <= 1), "TestClampImage failed - Assert 1/3"); Assert.True((curPixel.g >= 0) && (curPixel.g <= 1), "TestClampImage failed - Assert 2/3"); Assert.True((curPixel.b >= 0) && (curPixel.b <= 1), "TestClampImage failed - Assert 3/3"); } }
public void TestImagePigment() { HdrImage image = new HdrImage(2, 2); image.setPixel(0, 0, new Color(1.0f, 2.0f, 3.0f)); image.setPixel(1, 0, new Color(2.0f, 3.0f, 1.0f)); image.setPixel(0, 1, new Color(2.0f, 1.0f, 3.0f)); image.setPixel(1, 1, new Color(3.0f, 2.0f, 1.0f)); ImagePigment pig = new ImagePigment(image); Assert.True(pig.getColor(new Vec2D(0f, 0f)).isClose(new Color(1.0f, 2.0f, 3.0f)), "Test failed, 1/4"); Assert.True(pig.getColor(new Vec2D(0f, 1f)).isClose(new Color(2.0f, 1.0f, 3.0f)), "Test failed, 2/4"); Assert.True(pig.getColor(new Vec2D(1f, 0f)).isClose(new Color(2.0f, 3.0f, 1.0f)), "Test failed, 3/4"); Assert.True(pig.getColor(new Vec2D(1f, 1f)).isClose(new Color(3.0f, 2.0f, 1.0f)), "Test failed, 4/4"); }
public void TestSavePfm() { var MyImg = new HdrImage(3, 2); //Naive method MyImg.setPixel(0, 0, new Color(10.0f, 20.0f, 30.0f)); MyImg.setPixel(1, 0, new Color(40.0f, 50.0f, 60.0f)); MyImg.setPixel(2, 0, new Color(70.0f, 80.0f, 90.0f)); MyImg.setPixel(0, 1, new Color(100.0f, 200.0f, 300.0f)); MyImg.setPixel(1, 1, new Color(400.0f, 500.0f, 600.0f)); MyImg.setPixel(2, 1, new Color(700.0f, 800.0f, 900.0f)); byte[] ref_bytes = { 0x50, 0x46, 0x0a, 0x33, 0x20, 0x32, 0x0a, 0x2d, 0x31, 0x2e, 0x30, 0x0a, // Header 0x00, 0x00, 0xc8, 0x42, 0x00, 0x00, 0x48, 0x43, 0x00, 0x00, 0x96, 0x43, // Raster starts here 0x00, 0x00, 0xc8, 0x43, 0x00, 0x00, 0xfa, 0x43, 0x00, 0x00, 0x16, 0x44, 0x00, 0x00, 0x2f, 0x44, 0x00, 0x00, 0x48, 0x44, 0x00, 0x00, 0x61, 0x44, 0x00, 0x00, 0x20, 0x41, 0x00, 0x00, 0xa0, 0x41, 0x00, 0x00, 0xf0, 0x41, 0x00, 0x00, 0x20, 0x42, 0x00, 0x00, 0x48, 0x42, 0x00, 0x00, 0x70, 0x42, 0x00, 0x00, 0x8c, 0x42, 0x00, 0x00, 0xa0, 0x42, 0x00, 0x00, 0xb4, 0x42 }; using (MemoryStream memSt = new MemoryStream(84)) { MyImg.savePfm(memSt); Assert.True(memSt.GetBuffer().SequenceEqual(ref_bytes), "TestSavePfm failed - Assert 1/1"); } }