Commit 88e0127f authored by kobigurk's avatar kobigurk

API of TiffDecoder back to what it was - normalizeChannelsNumber moved to protected

test code unified - channels number is tested for other formats as well
parent 109e047a
...@@ -103,11 +103,11 @@ public: ...@@ -103,11 +103,11 @@ public:
size_t signatureLength() const; size_t signatureLength() const;
bool checkSignature( const string& signature ) const; bool checkSignature( const string& signature ) const;
int normalizeChannelsNumber(int channels) const;
ImageDecoder newDecoder() const; ImageDecoder newDecoder() const;
protected: protected:
void* m_tif; void* m_tif;
int normalizeChannelsNumber(int channels) const;
}; };
#endif #endif
......
...@@ -99,36 +99,12 @@ public: ...@@ -99,36 +99,12 @@ public:
{ {
if(ext_from_int(ext).empty()) if(ext_from_int(ext).empty())
continue; continue;
for (int num_channels = 1; num_channels <= 3; num_channels+=2) for (int num_channels = 1; num_channels <= 4; num_channels++)
{ {
ts->printf(ts->LOG, "image type depth:%d channels:%d ext: %s\n", CV_8U, num_channels, ext_from_int(ext).c_str()); if (num_channels == 2) continue;
Mat img(img_r * k, img_c * k, CV_MAKETYPE(CV_8U, num_channels), Scalar::all(0)); if (num_channels == 4 && ext!=3 /*TIFF*/) continue;
circle(img, Point2i((img_c * k) / 2, (img_r * k) / 2), cv::min((img_r * k), (img_c * k)) / 4 , Scalar::all(255));
string img_path = cv::tempfile(ext_from_int(ext).c_str());
ts->printf(ts->LOG, "writing image : %s\n", img_path.c_str());
imwrite(img_path, img);
ts->printf(ts->LOG, "reading test image : %s\n", img_path.c_str()); ts->printf(ts->LOG, "image type depth:%d channels:%d ext: %s\n", CV_8U, num_channels, ext_from_int(ext).c_str());
Mat img_test = imread(img_path, CV_LOAD_IMAGE_UNCHANGED);
if (img_test.empty()) ts->set_failed_test_info(ts->FAIL_MISMATCH);
CV_Assert(img.size() == img_test.size());
CV_Assert(img.type() == img_test.type());
double n = norm(img, img_test);
if ( n > 1.0)
{
ts->printf(ts->LOG, "norm = %f \n", n);
ts->set_failed_test_info(ts->FAIL_MISMATCH);
}
}
if (ext == 3 /*TIFF*/)
{
/* 4 channels should stay 4 channels */
int num_channels = 4;
ts->printf(ts->LOG, "image type depth:%d channels:%d ext: %s\n", CV_8U,num_channels, ext_from_int(ext).c_str());
Mat img(img_r * k, img_c * k, CV_MAKETYPE(CV_8U, num_channels), Scalar::all(0)); Mat img(img_r * k, img_c * k, CV_MAKETYPE(CV_8U, num_channels), Scalar::all(0));
circle(img, Point2i((img_c * k) / 2, (img_r * k) / 2), cv::min((img_r * k), (img_c * k)) / 4 , Scalar::all(255)); circle(img, Point2i((img_c * k) / 2, (img_r * k) / 2), cv::min((img_r * k), (img_c * k)) / 4 , Scalar::all(255));
...@@ -143,7 +119,7 @@ public: ...@@ -143,7 +119,7 @@ public:
CV_Assert(img.size() == img_test.size()); CV_Assert(img.size() == img_test.size());
CV_Assert(img.type() == img_test.type()); CV_Assert(img.type() == img_test.type());
CV_Assert(img_test.channels() == 4); CV_Assert(num_channels == img_test.channels());
double n = norm(img, img_test); double n = norm(img, img_test);
if ( n > 1.0) if ( n > 1.0)
...@@ -151,7 +127,6 @@ public: ...@@ -151,7 +127,6 @@ public:
ts->printf(ts->LOG, "norm = %f \n", n); ts->printf(ts->LOG, "norm = %f \n", n);
ts->set_failed_test_info(ts->FAIL_MISMATCH); ts->set_failed_test_info(ts->FAIL_MISMATCH);
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment