Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/image.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorVladimir S. FONOV <vladimir.fonov@gmail.com>2017-03-23 05:14:12 +0300
committerSoumith Chintala <soumith@gmail.com>2017-03-23 05:14:12 +0300
commit705393fabf51581b98142c9223c5aee6b62bb131 (patch)
treefd00058595869bf7bd5d67d88d3db0a343e7c95c /test
parentfc214c0292f014d71312b1bbb3c54a75e0cda3b6 (diff)
Added code to compress tensor into PNG in-memory similar to compressJPG, also added a test (#211)
Diffstat (limited to 'test')
-rw-r--r--test/test.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/test.lua b/test/test.lua
index 0a25cd9..839900a 100644
--- a/test/test.lua
+++ b/test/test.lua
@@ -410,8 +410,21 @@ function test.CompressAndDecompress()
img_compressed = image.compressJPG(img, quality)
local size_25 = img_compressed:size(1)
tester:assertlt(size_25, size_100, 'compressJPG quality setting error! ')
+
end
+function test.CompressAndDecompressPNG()
+ local img = image.lena()
+
+ local img_compressed_png = image.compressPNG(img)
+ local size_png = img_compressed_png:size(1)
+ local img_decompressed_png = image.decompressPNG(img_compressed_png)
+ local err_png = img_decompressed_png - img
+ local mean_err_png = err_png:mean()
+ local std_err_png = err_png:std()
+ tester:assertlt(mean_err_png, precision_mean, 'compressPNG error is too high! ')
+ tester:assertlt(std_err_png, precision_std, 'compressPNG error is too high! ')
+end
----------------------------------------------------------------------
-- Lab conversion test
-- These tests break if someone removes lena from the repo