From: Matti Picus Date: Thu, 20 Feb 2014 20:10:22 +0000 (+0200) Subject: add test (needs updated opencv_extra repo) X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~1314^2~581^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=46d128e073a0736f93301f98446f3e721a3e3fd1;p=platform%2Fupstream%2Fopencv.git add test (needs updated opencv_extra repo) --- diff --git a/modules/highgui/test/test_grfmt.cpp b/modules/highgui/test/test_grfmt.cpp index 86954e3..1fdf2c5 100644 --- a/modules/highgui/test/test_grfmt.cpp +++ b/modules/highgui/test/test_grfmt.cpp @@ -419,4 +419,46 @@ TEST(Highgui_Tiff, decode_tile16384x16384) remove(file3.c_str()); remove(file4.c_str()); } + +class CV_GrfmtReadTifTiledWithNotFullTiles: public cvtest::BaseTest +{ +public: + void run(int) + { + try + { + /* see issue #3472 - dealing with tiled images where the tile size is + * not a multiple of image size. + * The tiled images were created with 'convert' from ImageMagick, + * using the command 'convert -define tiff:tile-geometry=128x128 -depth [8|16] + * Note that the conversion to 16 bits expands the range from 0-255 to 0-255*255, + * so the test converts back but rounding errors cause small differences. + */ + cv::Mat img = imread(string(ts->get_data_path()) + "readwrite/non_tiled.tif",-1); + if (img.empty()) ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA); + ASSERT_TRUE(img.channels() == 3); + cv::Mat tiled8 = imread(string(ts->get_data_path()) + "readwrite/tiled_8.tif", -1); + if (tiled8.empty()) ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA); + ASSERT_PRED_FORMAT2(cvtest::MatComparator(0, 0), img, tiled8); + + cv::Mat tiled16 = imread(string(ts->get_data_path()) + "readwrite/tiled_16.tif", -1); + if (tiled16.empty()) ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA); + ASSERT_TRUE(tiled16.elemSize() == 6); + tiled16.convertTo(tiled8, CV_8UC3, 1./256.); + ASSERT_PRED_FORMAT2(cvtest::MatComparator(2, 0), img, tiled8); + // What about 32, 64 bit? + } + catch(...) + { + ts->set_failed_test_info(cvtest::TS::FAIL_EXCEPTION); + } + ts->set_failed_test_info(cvtest::TS::OK); + } +}; + +TEST(Highgui_Tiff, decode_tile_remainder) +{ + CV_GrfmtReadTifTiledWithNotFullTiles test; test.safe_run(); +} + #endif