Fixes, missing files, tests
This commit is contained in:
@@ -92,11 +92,9 @@ bool HdrDecoder::readData(Mat& img)
|
||||
|
||||
bool HdrDecoder::checkSignature( const String& signature ) const
|
||||
{
|
||||
if(signature.size() >= (m_signature.size()) &&
|
||||
!memcmp(signature.c_str(), m_signature.c_str(), m_signature.size()))
|
||||
return true;
|
||||
if(signature.size() >= (m_signature.size()) &&
|
||||
!memcmp(signature.c_str(), m_signature_alt.c_str(), m_signature_alt.size()))
|
||||
if(signature.size() >= m_signature.size() &&
|
||||
(!memcmp(signature.c_str(), m_signature.c_str(), m_signature.size()) ||
|
||||
!memcmp(signature.c_str(), m_signature_alt.c_str(), m_signature_alt.size())))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "grfmt_tiff.hpp"
|
||||
#include <opencv2/imgproc.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
@@ -413,22 +414,13 @@ bool TiffDecoder::readHdrData(Mat& img)
|
||||
size -= strip_size * sizeof(float);
|
||||
}
|
||||
close();
|
||||
ptr = img.ptr<float>();
|
||||
for(size_t i = 0; i < img.total(); i++, ptr += 3)
|
||||
if(photometric == PHOTOMETRIC_LOGLUV)
|
||||
{
|
||||
if(photometric == PHOTOMETRIC_LOGLUV)
|
||||
{
|
||||
float r = 3.240479f * ptr[0] + -1.537150f * ptr[1] + -0.498535f * ptr[2];
|
||||
float g = -0.969256f * ptr[0] + 1.875991f * ptr[1] + 0.041556f * ptr[2];
|
||||
float b = 0.055648f * ptr[0] + -0.204043f * ptr[1] + 1.057311f * ptr[2];
|
||||
ptr[0] = b; ptr[1] = g; ptr[2] = r;
|
||||
}
|
||||
else
|
||||
{
|
||||
float tmp = ptr[0];
|
||||
ptr[0] = ptr[2];
|
||||
ptr[2] = tmp;
|
||||
}
|
||||
cvtColor(img, img, COLOR_XYZ2BGR);
|
||||
}
|
||||
else
|
||||
{
|
||||
cvtColor(img, img, COLOR_RGB2BGR);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -614,16 +606,10 @@ bool TiffEncoder::writeLibTiff( const Mat& img, const std::vector<int>& params)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TiffEncoder::writeHdr(const Mat& img)
|
||||
bool TiffEncoder::writeHdr(const Mat& _img)
|
||||
{
|
||||
float *ptr = const_cast<float*>(img.ptr<float>());
|
||||
for(size_t i = 0; i < img.total(); i++, ptr += 3)
|
||||
{
|
||||
float x = 0.412453f * ptr[2] + 0.357580f * ptr[1] + 0.180423f * ptr[0];
|
||||
float y = 0.212671f * ptr[2] + 0.715160f * ptr[1] + 0.072169f * ptr[0];
|
||||
float z = 0.019334f * ptr[2] + 0.119193f * ptr[1] + 0.950227f * ptr[0];
|
||||
ptr[0] = x; ptr[1] = y; ptr[2] = z;
|
||||
}
|
||||
Mat img;
|
||||
cvtColor(_img, img, COLOR_BGR2XYZ);
|
||||
TIFF* tif = TIFFOpen(m_filename.c_str(), "w");
|
||||
if (!tif)
|
||||
{
|
||||
@@ -638,7 +624,7 @@ bool TiffEncoder::writeHdr(const Mat& img)
|
||||
TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_FLOAT);
|
||||
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
|
||||
int strip_size = 3 * img.cols;
|
||||
ptr = const_cast<float*>(img.ptr<float>());
|
||||
float *ptr = const_cast<float*>(img.ptr<float>());
|
||||
for (int i = 0; i < img.rows; i++, ptr += strip_size)
|
||||
{
|
||||
TIFFWriteEncodedStrip(tif, i, ptr, strip_size * sizeof(float));
|
||||
|
||||
@@ -53,7 +53,7 @@ enum TiffCompression
|
||||
{
|
||||
TIFF_UNCOMP = 1,
|
||||
TIFF_HUFFMAN = 2,
|
||||
TIFF_PACKBITS = 32773,
|
||||
TIFF_PACKBITS = 32773
|
||||
};
|
||||
|
||||
enum TiffByteOrder
|
||||
|
||||
Reference in New Issue
Block a user