Commit c9ace388 authored by Fedor Morozov's avatar Fedor Morozov Committed by Alexander Shishkov

Docs updated, added InputArray, fixes for makePtr,...

parent f99be6bd
...@@ -39,4 +39,3 @@ ...@@ -39,4 +39,3 @@
#7 & #8 & #9 #7 & #8 & #9
\end{bmatrix} \end{bmatrix}
} }
...@@ -40,13 +40,13 @@ Explanation ...@@ -40,13 +40,13 @@ Explanation
loadExposureSeq(argv[1], images, times); loadExposureSeq(argv[1], images, times);
Firstly we load input images and exposure times from user-defined folder. The folder should contain images and *list.txt* - file that contains file names and inverse exposure times. Firstly we load input images and exposure times from user-defined folder. The folder should contain images and *list.txt* - file that contains file names and inverse exposure times.
For our image sequence the list is following: For our image sequence the list is following:
.. code-block:: none .. code-block:: none
memorial00.png 0.03125 memorial00.png 0.03125
memorial01.png 0.0625 memorial01.png 0.0625
... ...
memorial15.png 1024 memorial15.png 1024
...@@ -57,9 +57,9 @@ Explanation ...@@ -57,9 +57,9 @@ Explanation
Mat response; Mat response;
Ptr<CalibrateDebevec> calibrate = createCalibrateDebevec(); Ptr<CalibrateDebevec> calibrate = createCalibrateDebevec();
calibrate->process(images, response, times); calibrate->process(images, response, times);
It is necessary to know camera response function (CRF) for a lot of HDR construction algorithms. We use one of the calibration algorithms to estimate inverse CRF for all 256 pixel values. It is necessary to know camera response function (CRF) for a lot of HDR construction algorithms. We use one of the calibration algorithms to estimate inverse CRF for all 256 pixel values.
3. **Make HDR image** 3. **Make HDR image**
.. code-block:: cpp .. code-block:: cpp
...@@ -67,39 +67,39 @@ Explanation ...@@ -67,39 +67,39 @@ Explanation
Mat hdr; Mat hdr;
Ptr<MergeDebevec> merge_debevec = createMergeDebevec(); Ptr<MergeDebevec> merge_debevec = createMergeDebevec();
merge_debevec->process(images, hdr, times, response); merge_debevec->process(images, hdr, times, response);
We use Debevec's weighting scheme to construct HDR image using response calculated in the previous item. We use Debevec's weighting scheme to construct HDR image using response calculated in the previous item.
4. **Tonemap HDR image** 4. **Tonemap HDR image**
.. code-block:: cpp .. code-block:: cpp
Mat ldr; Mat ldr;
Ptr<TonemapDurand> tonemap = createTonemapDurand(2.2f); Ptr<TonemapDurand> tonemap = createTonemapDurand(2.2f);
tonemap->process(hdr, ldr); tonemap->process(hdr, ldr);
Since we want to see our results on common LDR display we have to map our HDR image to 8-bit range preserving most details. It is the main goal of tonemapping methods. We use tonemapper with bilateral filtering and set 2.2 as the value for gamma correction. Since we want to see our results on common LDR display we have to map our HDR image to 8-bit range preserving most details. It is the main goal of tonemapping methods. We use tonemapper with bilateral filtering and set 2.2 as the value for gamma correction.
5. **Perform exposure fusion** 5. **Perform exposure fusion**
.. code-block:: cpp .. code-block:: cpp
Mat fusion; Mat fusion;
Ptr<MergeMertens> merge_mertens = createMergeMertens(); Ptr<MergeMertens> merge_mertens = createMergeMertens();
merge_mertens->process(images, fusion); merge_mertens->process(images, fusion);
There is an alternative way to merge our exposures in case when we don't need HDR image. This process is called exposure fusion and produces LDR image that doesn't require gamma correction. It also doesn't use exposure values of the photographs. There is an alternative way to merge our exposures in case when we don't need HDR image. This process is called exposure fusion and produces LDR image that doesn't require gamma correction. It also doesn't use exposure values of the photographs.
6. **Write results** 6. **Write results**
.. code-block:: cpp .. code-block:: cpp
imwrite("fusion.png", fusion * 255); imwrite("fusion.png", fusion * 255);
imwrite("ldr.png", ldr * 255); imwrite("ldr.png", ldr * 255);
imwrite("hdr.hdr", hdr); imwrite("hdr.hdr", hdr);
Now it's time to look at the results. Note that HDR image can't be stored in one of common image formats, so we save it to Radiance image (.hdr). Also all HDR imaging functions return results in [0, 1] range so we should multiply result by 255. Now it's time to look at the results. Note that HDR image can't be stored in one of common image formats, so we save it to Radiance image (.hdr). Also all HDR imaging functions return results in [0, 1] range so we should multiply result by 255.
Results Results
======= =======
...@@ -111,7 +111,7 @@ Tonemapped image ...@@ -111,7 +111,7 @@ Tonemapped image
:width: 242pt :width: 242pt
:alt: Tonemapped image :alt: Tonemapped image
:align: center :align: center
Exposure fusion Exposure fusion
------------------ ------------------
......
...@@ -155,7 +155,7 @@ As always, we would be happy to hear your comments and receive your contribution ...@@ -155,7 +155,7 @@ As always, we would be happy to hear your comments and receive your contribution
:height: 80pt :height: 80pt
:width: 80pt :width: 80pt
:alt: photo Icon :alt: photo Icon
* :ref:`Table-Of-Content-GPU` * :ref:`Table-Of-Content-GPU`
.. tabularcolumns:: m{100pt} m{300pt} .. tabularcolumns:: m{100pt} m{300pt}
......
...@@ -49,10 +49,10 @@ namespace cv ...@@ -49,10 +49,10 @@ namespace cv
HdrDecoder::HdrDecoder() HdrDecoder::HdrDecoder()
{ {
m_signature = "#?RGBE"; m_signature = "#?RGBE";
m_signature_alt = "#?RADIANCE"; m_signature_alt = "#?RADIANCE";
file = NULL; file = NULL;
m_type = CV_32FC3; m_type = CV_32FC3;
} }
HdrDecoder::~HdrDecoder() HdrDecoder::~HdrDecoder()
...@@ -61,61 +61,61 @@ HdrDecoder::~HdrDecoder() ...@@ -61,61 +61,61 @@ HdrDecoder::~HdrDecoder()
size_t HdrDecoder::signatureLength() const size_t HdrDecoder::signatureLength() const
{ {
return m_signature.size() > m_signature_alt.size() ? return m_signature.size() > m_signature_alt.size() ?
m_signature.size() : m_signature_alt.size(); m_signature.size() : m_signature_alt.size();
} }
bool HdrDecoder::readHeader() bool HdrDecoder::readHeader()
{ {
file = fopen(m_filename.c_str(), "rb"); file = fopen(m_filename.c_str(), "rb");
if(!file) { if(!file) {
return false; return false;
} }
RGBE_ReadHeader(file, &m_width, &m_height, NULL); RGBE_ReadHeader(file, &m_width, &m_height, NULL);
if(m_width <= 0 || m_height <= 0) { if(m_width <= 0 || m_height <= 0) {
fclose(file); fclose(file);
file = NULL; file = NULL;
return false; return false;
} }
return true; return true;
} }
bool HdrDecoder::readData(Mat& _img) bool HdrDecoder::readData(Mat& _img)
{ {
Mat img(m_height, m_width, CV_32FC3); Mat img(m_height, m_width, CV_32FC3);
if(!file) { if(!file) {
if(!readHeader()) { if(!readHeader()) {
return false; return false;
} }
} }
RGBE_ReadPixels_RLE(file, const_cast<float*>(img.ptr<float>()), img.cols, img.rows); RGBE_ReadPixels_RLE(file, const_cast<float*>(img.ptr<float>()), img.cols, img.rows);
fclose(file); file = NULL; fclose(file); file = NULL;
if(_img.depth() == img.depth()) { if(_img.depth() == img.depth()) {
img.convertTo(_img, _img.type()); img.convertTo(_img, _img.type());
} else { } else {
img.convertTo(_img, _img.type(), 255); img.convertTo(_img, _img.type(), 255);
} }
return true; return true;
} }
bool HdrDecoder::checkSignature( const String& signature ) const bool HdrDecoder::checkSignature( const String& signature ) const
{ {
if(signature.size() >= m_signature.size() && if(signature.size() >= m_signature.size() &&
(!memcmp(signature.c_str(), m_signature.c_str(), 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()))) !memcmp(signature.c_str(), m_signature_alt.c_str(), m_signature_alt.size())))
return true; return true;
return false; return false;
} }
ImageDecoder HdrDecoder::newDecoder() const ImageDecoder HdrDecoder::newDecoder() const
{ {
return new HdrDecoder; return makePtr<HdrDecoder>();
} }
HdrEncoder::HdrEncoder() HdrEncoder::HdrEncoder()
{ {
m_description = "Radiance HDR (*.hdr;*.pic)"; m_description = "Radiance HDR (*.hdr;*.pic)";
} }
HdrEncoder::~HdrEncoder() HdrEncoder::~HdrEncoder()
...@@ -124,41 +124,41 @@ HdrEncoder::~HdrEncoder() ...@@ -124,41 +124,41 @@ HdrEncoder::~HdrEncoder()
bool HdrEncoder::write( const Mat& input_img, const std::vector<int>& params ) bool HdrEncoder::write( const Mat& input_img, const std::vector<int>& params )
{ {
Mat img; Mat img;
CV_Assert(input_img.channels() == 3 || input_img.channels() == 1); CV_Assert(input_img.channels() == 3 || input_img.channels() == 1);
if(input_img.channels() == 1) { if(input_img.channels() == 1) {
std::vector<Mat> splitted(3, input_img); std::vector<Mat> splitted(3, input_img);
merge(splitted, img); merge(splitted, img);
} else { } else {
input_img.copyTo(img); input_img.copyTo(img);
} }
if(img.depth() != CV_32F) { if(img.depth() != CV_32F) {
img.convertTo(img, CV_32FC3, 1/255.0f); img.convertTo(img, CV_32FC3, 1/255.0f);
} }
CV_Assert(params.empty() || params[0] == HDR_NONE || params[0] == HDR_RLE); CV_Assert(params.empty() || params[0] == HDR_NONE || params[0] == HDR_RLE);
FILE *fout = fopen(m_filename.c_str(), "wb"); FILE *fout = fopen(m_filename.c_str(), "wb");
if(!fout) { if(!fout) {
return false; return false;
} }
RGBE_WriteHeader(fout, img.cols, img.rows, NULL); RGBE_WriteHeader(fout, img.cols, img.rows, NULL);
if(params.empty() || params[0] == HDR_RLE) { if(params.empty() || params[0] == HDR_RLE) {
RGBE_WritePixels_RLE(fout, const_cast<float*>(img.ptr<float>()), img.cols, img.rows); RGBE_WritePixels_RLE(fout, const_cast<float*>(img.ptr<float>()), img.cols, img.rows);
} else { } else {
RGBE_WritePixels(fout, const_cast<float*>(img.ptr<float>()), img.cols * img.rows); RGBE_WritePixels(fout, const_cast<float*>(img.ptr<float>()), img.cols * img.rows);
} }
fclose(fout); fclose(fout);
return true; return true;
} }
ImageEncoder HdrEncoder::newEncoder() const ImageEncoder HdrEncoder::newEncoder() const
{ {
return new HdrEncoder; return makePtr<HdrEncoder>();
} }
bool HdrEncoder::isFormatSupported( int depth ) const { bool HdrEncoder::isFormatSupported( int depth ) const {
return depth != CV_64F; return depth != CV_64F;
} }
} }
...@@ -58,29 +58,29 @@ enum HdrCompression ...@@ -58,29 +58,29 @@ enum HdrCompression
class HdrDecoder : public BaseImageDecoder class HdrDecoder : public BaseImageDecoder
{ {
public: public:
HdrDecoder(); HdrDecoder();
~HdrDecoder(); ~HdrDecoder();
bool readHeader(); bool readHeader();
bool readData( Mat& img ); bool readData( Mat& img );
bool checkSignature( const String& signature ) const; bool checkSignature( const String& signature ) const;
ImageDecoder newDecoder() const; ImageDecoder newDecoder() const;
size_t signatureLength() const; size_t signatureLength() const;
protected: protected:
String m_signature_alt; String m_signature_alt;
FILE *file; FILE *file;
}; };
// ... writer // ... writer
class HdrEncoder : public BaseImageEncoder class HdrEncoder : public BaseImageEncoder
{ {
public: public:
HdrEncoder(); HdrEncoder();
~HdrEncoder(); ~HdrEncoder();
bool write( const Mat& img, const std::vector<int>& params ); bool write( const Mat& img, const std::vector<int>& params );
ImageEncoder newEncoder() const; ImageEncoder newEncoder() const;
bool isFormatSupported( int depth ) const; bool isFormatSupported( int depth ) const;
protected: protected:
}; };
} }
......
...@@ -72,7 +72,7 @@ TiffDecoder::TiffDecoder() ...@@ -72,7 +72,7 @@ TiffDecoder::TiffDecoder()
TIFFSetErrorHandler( GrFmtSilentTIFFErrorHandler ); TIFFSetErrorHandler( GrFmtSilentTIFFErrorHandler );
TIFFSetWarningHandler( GrFmtSilentTIFFErrorHandler ); TIFFSetWarningHandler( GrFmtSilentTIFFErrorHandler );
} }
m_hdr = false; m_hdr = false;
} }
...@@ -135,13 +135,13 @@ bool TiffDecoder::readHeader() ...@@ -135,13 +135,13 @@ bool TiffDecoder::readHeader()
m_width = wdth; m_width = wdth;
m_height = hght; m_height = hght;
if((bpp == 32 && ncn == 3) || photometric == PHOTOMETRIC_LOGLUV) if((bpp == 32 && ncn == 3) || photometric == PHOTOMETRIC_LOGLUV)
{ {
m_type = CV_32FC3; m_type = CV_32FC3;
m_hdr = true; m_hdr = true;
return true; return true;
} }
m_hdr = false; m_hdr = false;
if( bpp > 8 && if( bpp > 8 &&
((photometric != 2 && photometric != 1) || ((photometric != 2 && photometric != 1) ||
...@@ -181,10 +181,10 @@ bool TiffDecoder::readHeader() ...@@ -181,10 +181,10 @@ bool TiffDecoder::readHeader()
bool TiffDecoder::readData( Mat& img ) bool TiffDecoder::readData( Mat& img )
{ {
if(m_hdr && img.type() == CV_32FC3) if(m_hdr && img.type() == CV_32FC3)
{ {
return readHdrData(img); return readHdrData(img);
} }
bool result = false; bool result = false;
bool color = img.channels() > 1; bool color = img.channels() > 1;
uchar* data = img.data; uchar* data = img.data;
...@@ -394,35 +394,35 @@ bool TiffDecoder::readData( Mat& img ) ...@@ -394,35 +394,35 @@ bool TiffDecoder::readData( Mat& img )
return result; return result;
} }
bool TiffDecoder::readHdrData(Mat& img) bool TiffDecoder::readHdrData(Mat& img)
{ {
int rows_per_strip = 0, photometric = 0; int rows_per_strip = 0, photometric = 0;
if(!m_tif) if(!m_tif)
{ {
return false; return false;
} }
TIFF *tif = static_cast<TIFF*>(m_tif); TIFF *tif = static_cast<TIFF*>(m_tif);
TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &rows_per_strip); TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &rows_per_strip);
TIFFGetField( tif, TIFFTAG_PHOTOMETRIC, &photometric ); TIFFGetField( tif, TIFFTAG_PHOTOMETRIC, &photometric );
TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_FLOAT); TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_FLOAT);
int size = 3 * m_width * m_height * sizeof (float); int size = 3 * m_width * m_height * sizeof (float);
int strip_size = 3 * m_width * rows_per_strip; int strip_size = 3 * m_width * rows_per_strip;
float *ptr = img.ptr<float>(); float *ptr = img.ptr<float>();
for (size_t i = 0; i < TIFFNumberOfStrips(tif); i++, ptr += strip_size) for (size_t i = 0; i < TIFFNumberOfStrips(tif); i++, ptr += strip_size)
{ {
TIFFReadEncodedStrip(tif, i, ptr, size); TIFFReadEncodedStrip(tif, i, ptr, size);
size -= strip_size * sizeof(float); size -= strip_size * sizeof(float);
} }
close(); close();
if(photometric == PHOTOMETRIC_LOGLUV) if(photometric == PHOTOMETRIC_LOGLUV)
{ {
cvtColor(img, img, COLOR_XYZ2BGR); cvtColor(img, img, COLOR_XYZ2BGR);
} }
else else
{ {
cvtColor(img, img, COLOR_RGB2BGR); cvtColor(img, img, COLOR_RGB2BGR);
} }
return true; return true;
} }
#endif #endif
...@@ -452,8 +452,8 @@ bool TiffEncoder::isFormatSupported( int depth ) const ...@@ -452,8 +452,8 @@ bool TiffEncoder::isFormatSupported( int depth ) const
{ {
#ifdef HAVE_TIFF #ifdef HAVE_TIFF
return depth == CV_8U || depth == CV_16U || depth == CV_32F; return depth == CV_8U || depth == CV_16U || depth == CV_32F;
#else #else
return depth == CV_8U || depth == CV_16U; return depth == CV_8U || depth == CV_16U;
#endif #endif
} }
...@@ -608,29 +608,29 @@ bool TiffEncoder::writeLibTiff( const Mat& img, const std::vector<int>& params) ...@@ -608,29 +608,29 @@ bool TiffEncoder::writeLibTiff( const Mat& img, const std::vector<int>& params)
bool TiffEncoder::writeHdr(const Mat& _img) bool TiffEncoder::writeHdr(const Mat& _img)
{ {
Mat img; Mat img;
cvtColor(_img, img, COLOR_BGR2XYZ); cvtColor(_img, img, COLOR_BGR2XYZ);
TIFF* tif = TIFFOpen(m_filename.c_str(), "w"); TIFF* tif = TIFFOpen(m_filename.c_str(), "w");
if (!tif) if (!tif)
{ {
return false; return false;
} }
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, img.cols); TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, img.cols);
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, img.rows); TIFFSetField(tif, TIFFTAG_IMAGELENGTH, img.rows);
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3); TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3);
TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_SGILOG); TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_SGILOG);
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_LOGLUV); TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_LOGLUV);
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_FLOAT); TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_FLOAT);
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1); TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
int strip_size = 3 * img.cols; int strip_size = 3 * img.cols;
float *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) for (int i = 0; i < img.rows; i++, ptr += strip_size)
{ {
TIFFWriteEncodedStrip(tif, i, ptr, strip_size * sizeof(float)); TIFFWriteEncodedStrip(tif, i, ptr, strip_size * sizeof(float));
} }
TIFFClose(tif); TIFFClose(tif);
return true; return true;
} }
#endif #endif
...@@ -645,10 +645,10 @@ bool TiffEncoder::write( const Mat& img, const std::vector<int>& /*params*/) ...@@ -645,10 +645,10 @@ bool TiffEncoder::write( const Mat& img, const std::vector<int>& /*params*/)
int width = img.cols, height = img.rows; int width = img.cols, height = img.rows;
int depth = img.depth(); int depth = img.depth();
#ifdef HAVE_TIFF #ifdef HAVE_TIFF
if(img.type() == CV_32FC3) if(img.type() == CV_32FC3)
{ {
return writeHdr(img); return writeHdr(img);
} }
#endif #endif
if (depth != CV_8U && depth != CV_16U) if (depth != CV_8U && depth != CV_16U)
......
...@@ -108,8 +108,8 @@ public: ...@@ -108,8 +108,8 @@ public:
protected: protected:
void* m_tif; void* m_tif;
int normalizeChannelsNumber(int channels) const; int normalizeChannelsNumber(int channels) const;
bool readHdrData(Mat& img); bool readHdrData(Mat& img);
bool m_hdr; bool m_hdr;
}; };
#endif #endif
...@@ -132,7 +132,7 @@ protected: ...@@ -132,7 +132,7 @@ protected:
int count, int value ); int count, int value );
bool writeLibTiff( const Mat& img, const std::vector<int>& params ); bool writeLibTiff( const Mat& img, const std::vector<int>& params );
bool writeHdr( const Mat& img ); bool writeHdr( const Mat& img );
}; };
} }
......
...@@ -59,15 +59,10 @@ struct ImageCodecInitializer ...@@ -59,15 +59,10 @@ struct ImageCodecInitializer
{ {
ImageCodecInitializer() ImageCodecInitializer()
{ {
<<<<<<< HEAD
decoders.push_back( new BmpDecoder );
encoders.push_back( new BmpEncoder );
decoders.push_back( new HdrDecoder );
encoders.push_back( new HdrEncoder );
=======
decoders.push_back( makePtr<BmpDecoder>() ); decoders.push_back( makePtr<BmpDecoder>() );
encoders.push_back( makePtr<BmpEncoder>() ); encoders.push_back( makePtr<BmpEncoder>() );
>>>>>>> 99a43257d5912ff215016e1cf5f4e0c2a934b72f decoders.push_back( makePtr<HdrDecoder>() );
encoders.push_back( makePtr<HdrEncoder>() );
#ifdef HAVE_JPEG #ifdef HAVE_JPEG
decoders.push_back( makePtr<JpegDecoder>() ); decoders.push_back( makePtr<JpegDecoder>() );
encoders.push_back( makePtr<JpegEncoder>() ); encoders.push_back( makePtr<JpegEncoder>() );
......
This diff is collapsed.
...@@ -51,13 +51,13 @@ ...@@ -51,13 +51,13 @@
typedef struct { typedef struct {
int valid; /* indicate which fields are valid */ int valid; /* indicate which fields are valid */
char programtype[16]; /* listed at beginning of file to identify it char programtype[16]; /* listed at beginning of file to identify it
* after "#?". defaults to "RGBE" */ * after "#?". defaults to "RGBE" */
float gamma; /* image has already been gamma corrected with float gamma; /* image has already been gamma corrected with
* given gamma. defaults to 1.0 (no correction) */ * given gamma. defaults to 1.0 (no correction) */
float exposure; /* a value of 1.0 in an image corresponds to float exposure; /* a value of 1.0 in an image corresponds to
* <exposure> watts/steradian/m^2. * <exposure> watts/steradian/m^2.
* defaults to 1.0 */ * defaults to 1.0 */
} rgbe_header_info; } rgbe_header_info;
/* flags indicating which fields in an rgbe_header_info are valid */ /* flags indicating which fields in an rgbe_header_info are valid */
...@@ -82,11 +82,8 @@ int RGBE_ReadPixels(FILE *fp, float *data, int numpixels); ...@@ -82,11 +82,8 @@ int RGBE_ReadPixels(FILE *fp, float *data, int numpixels);
/* read or write run length encoded files */ /* read or write run length encoded files */
/* must be called to read or write whole scanlines */ /* must be called to read or write whole scanlines */
int RGBE_WritePixels_RLE(FILE *fp, float *data, int scanline_width, int RGBE_WritePixels_RLE(FILE *fp, float *data, int scanline_width,
int num_scanlines); int num_scanlines);
int RGBE_ReadPixels_RLE(FILE *fp, float *data, int scanline_width, int RGBE_ReadPixels_RLE(FILE *fp, float *data, int scanline_width,
int num_scanlines); int num_scanlines);
#endif/*_RGBE_HDR_H_*/ #endif/*_RGBE_HDR_H_*/
...@@ -479,11 +479,7 @@ TEST(Highgui_WebP, encode_decode_lossless_webp) ...@@ -479,11 +479,7 @@ TEST(Highgui_WebP, encode_decode_lossless_webp)
TEST(Highgui_WebP, encode_decode_lossy_webp) TEST(Highgui_WebP, encode_decode_lossy_webp)
{ {
cvtest::TS& ts = *cvtest::TS::ptr(); cvtest::TS& ts = *cvtest::TS::ptr();
<<<<<<< HEAD
string input = string(ts.get_data_path()) + "/../cv/shared/lena.png";
=======
std::string input = std::string(ts.get_data_path()) + "../cv/shared/lena.png"; std::string input = std::string(ts.get_data_path()) + "../cv/shared/lena.png";
>>>>>>> 99a43257d5912ff215016e1cf5f4e0c2a934b72f
cv::Mat img = cv::imread(input); cv::Mat img = cv::imread(input);
ASSERT_FALSE(img.empty()); ASSERT_FALSE(img.empty());
...@@ -533,24 +529,24 @@ TEST(Highgui_WebP, encode_decode_with_alpha_webp) ...@@ -533,24 +529,24 @@ TEST(Highgui_WebP, encode_decode_with_alpha_webp)
TEST(Highgui_Hdr, regression) TEST(Highgui_Hdr, regression)
{ {
string folder = string(cvtest::TS::ptr()->get_data_path()) + "/readwrite/"; string folder = string(cvtest::TS::ptr()->get_data_path()) + "/readwrite/";
string name_rle = folder + "rle.hdr"; string name_rle = folder + "rle.hdr";
string name_no_rle = folder + "no_rle.hdr"; string name_no_rle = folder + "no_rle.hdr";
Mat img_rle = imread(name_rle, -1); Mat img_rle = imread(name_rle, -1);
ASSERT_FALSE(img_rle.empty()) << "Could not open " << name_rle; ASSERT_FALSE(img_rle.empty()) << "Could not open " << name_rle;
Mat img_no_rle = imread(name_no_rle, -1); Mat img_no_rle = imread(name_no_rle, -1);
ASSERT_FALSE(img_no_rle.empty()) << "Could not open " << name_no_rle; ASSERT_FALSE(img_no_rle.empty()) << "Could not open " << name_no_rle;
double min = 0.0, max = 1.0; double min = 0.0, max = 1.0;
minMaxLoc(abs(img_rle - img_no_rle), &min, &max); minMaxLoc(abs(img_rle - img_no_rle), &min, &max);
ASSERT_FALSE(max > DBL_EPSILON); ASSERT_FALSE(max > DBL_EPSILON);
string tmp_file_name = tempfile(".hdr"); string tmp_file_name = tempfile(".hdr");
vector<int>param(1); vector<int>param(1);
for(int i = 0; i < 2; i++) { for(int i = 0; i < 2; i++) {
param[0] = i; param[0] = i;
imwrite(tmp_file_name, img_rle, param); imwrite(tmp_file_name, img_rle, param);
Mat written_img = imread(tmp_file_name, -1); Mat written_img = imread(tmp_file_name, -1);
ASSERT_FALSE(written_img.empty()) << "Could not open " << tmp_file_name; ASSERT_FALSE(written_img.empty()) << "Could not open " << tmp_file_name;
minMaxLoc(abs(img_rle - written_img), &min, &max); minMaxLoc(abs(img_rle - written_img), &min, &max);
ASSERT_FALSE(max > DBL_EPSILON); ASSERT_FALSE(max > DBL_EPSILON);
} }
} }
This diff is collapsed.
...@@ -127,12 +127,12 @@ public: ...@@ -127,12 +127,12 @@ public:
CV_WRAP virtual void setSigmaColor(float sigma_color) = 0; CV_WRAP virtual void setSigmaColor(float sigma_color) = 0;
}; };
CV_EXPORTS_W Ptr<TonemapDurand> CV_EXPORTS_W Ptr<TonemapDurand>
createTonemapDurand(float gamma = 1.0f, float contrast = 4.0f, float saturation = 1.0f, float sigma_space = 2.0f, float sigma_color = 2.0f); createTonemapDurand(float gamma = 1.0f, float contrast = 4.0f, float saturation = 1.0f, float sigma_space = 2.0f, float sigma_color = 2.0f);
// "Dynamic Range Reduction Inspired by Photoreceptor Physiology", Reinhard, Devlin, 2005 // "Dynamic Range Reduction Inspired by Photoreceptor Physiology", Reinhard, Devlin, 2005
class CV_EXPORTS_W TonemapReinhardDevlin : public Tonemap class CV_EXPORTS_W TonemapReinhard : public Tonemap
{ {
public: public:
CV_WRAP virtual float getIntensity() const = 0; CV_WRAP virtual float getIntensity() const = 0;
...@@ -145,8 +145,8 @@ public: ...@@ -145,8 +145,8 @@ public:
CV_WRAP virtual void setColorAdaptation(float color_adapt) = 0; CV_WRAP virtual void setColorAdaptation(float color_adapt) = 0;
}; };
CV_EXPORTS_W Ptr<TonemapReinhardDevlin> CV_EXPORTS_W Ptr<TonemapReinhard>
createTonemapReinhardDevlin(float gamma = 1.0f, float intensity = 0.0f, float light_adapt = 1.0f, float color_adapt = 0.0f); createTonemapReinhard(float gamma = 1.0f, float intensity = 0.0f, float light_adapt = 1.0f, float color_adapt = 0.0f);
// "Perceptual Framework for Contrast Processing of High Dynamic Range Images", Mantiuk et al., 2006 // "Perceptual Framework for Contrast Processing of High Dynamic Range Images", Mantiuk et al., 2006
...@@ -160,29 +160,29 @@ public: ...@@ -160,29 +160,29 @@ public:
CV_WRAP virtual void setSaturation(float saturation) = 0; CV_WRAP virtual void setSaturation(float saturation) = 0;
}; };
CV_EXPORTS_W Ptr<TonemapMantiuk> CV_EXPORTS_W Ptr<TonemapMantiuk>
createTonemapMantiuk(float gamma = 1.0f, float scale = 0.7f, float saturation = 1.0f); createTonemapMantiuk(float gamma = 1.0f, float scale = 0.7f, float saturation = 1.0f);
class CV_EXPORTS_W ExposureAlign : public Algorithm class CV_EXPORTS_W AlignExposures : public Algorithm
{ {
public: public:
CV_WRAP virtual void process(InputArrayOfArrays src, std::vector<Mat>& dst, CV_WRAP virtual void process(InputArrayOfArrays src, std::vector<Mat>& dst,
const std::vector<float>& times, InputArray response) = 0; InputArray times, InputArray response) = 0;
}; };
// "Fast, Robust Image Registration for Compositing High Dynamic Range Photographs from Handheld Exposures", Ward, 2003 // "Fast, Robust Image Registration for Compositing High Dynamic Range Photographs from Handheld Exposures", Ward, 2003
class CV_EXPORTS_W AlignMTB : public ExposureAlign class CV_EXPORTS_W AlignMTB : public AlignExposures
{ {
public: public:
CV_WRAP virtual void process(InputArrayOfArrays src, std::vector<Mat>& dst, CV_WRAP virtual void process(InputArrayOfArrays src, std::vector<Mat>& dst,
const std::vector<float>& times, InputArray response) = 0; InputArray times, InputArray response) = 0;
CV_WRAP virtual void process(InputArrayOfArrays src, std::vector<Mat>& dst) = 0; CV_WRAP virtual void process(InputArrayOfArrays src, std::vector<Mat>& dst) = 0;
CV_WRAP virtual void calculateShift(InputArray img0, InputArray img1, Point& shift) = 0; CV_WRAP virtual Point calculateShift(InputArray img0, InputArray img1) = 0;
CV_WRAP virtual void shiftMat(InputArray src, OutputArray dst, const Point shift) = 0; CV_WRAP virtual void shiftMat(InputArray src, OutputArray dst, const Point shift) = 0;
CV_WRAP virtual void computeBitmaps(Mat& img, Mat& tb, Mat& eb) = 0; CV_WRAP virtual void computeBitmaps(InputArray img, OutputArray tb, OutputArray eb) = 0;
CV_WRAP virtual int getMaxBits() const = 0; CV_WRAP virtual int getMaxBits() const = 0;
CV_WRAP virtual void setMaxBits(int max_bits) = 0; CV_WRAP virtual void setMaxBits(int max_bits) = 0;
...@@ -196,20 +196,20 @@ public: ...@@ -196,20 +196,20 @@ public:
CV_EXPORTS_W Ptr<AlignMTB> createAlignMTB(int max_bits = 6, int exclude_range = 4, bool cut = true); CV_EXPORTS_W Ptr<AlignMTB> createAlignMTB(int max_bits = 6, int exclude_range = 4, bool cut = true);
class CV_EXPORTS_W ExposureCalibrate : public Algorithm class CV_EXPORTS_W CalibrateCRF : public Algorithm
{ {
public: public:
CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, std::vector<float>& times) = 0; CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, InputArray times) = 0;
}; };
// "Recovering High Dynamic Range Radiance Maps from Photographs", Debevec, Malik, 1997 // "Recovering High Dynamic Range Radiance Maps from Photographs", Debevec, Malik, 1997
class CV_EXPORTS_W CalibrateDebevec : public ExposureCalibrate class CV_EXPORTS_W CalibrateDebevec : public CalibrateCRF
{ {
public: public:
CV_WRAP virtual float getLambda() const = 0; CV_WRAP virtual float getLambda() const = 0;
CV_WRAP virtual void setLambda(float lambda) = 0; CV_WRAP virtual void setLambda(float lambda) = 0;
CV_WRAP virtual int getSamples() const = 0; CV_WRAP virtual int getSamples() const = 0;
CV_WRAP virtual void setSamples(int samples) = 0; CV_WRAP virtual void setSamples(int samples) = 0;
...@@ -221,46 +221,46 @@ CV_EXPORTS_W Ptr<CalibrateDebevec> createCalibrateDebevec(int samples = 70, floa ...@@ -221,46 +221,46 @@ CV_EXPORTS_W Ptr<CalibrateDebevec> createCalibrateDebevec(int samples = 70, floa
// "Dynamic range improvement through multiple exposures", Robertson et al., 1999 // "Dynamic range improvement through multiple exposures", Robertson et al., 1999
class CV_EXPORTS_W CalibrateRobertson : public ExposureCalibrate class CV_EXPORTS_W CalibrateRobertson : public CalibrateCRF
{ {
public: public:
CV_WRAP virtual int getMaxIter() const = 0; CV_WRAP virtual int getMaxIter() const = 0;
CV_WRAP virtual void setMaxIter(int max_iter) = 0; CV_WRAP virtual void setMaxIter(int max_iter) = 0;
CV_WRAP virtual float getThreshold() const = 0; CV_WRAP virtual float getThreshold() const = 0;
CV_WRAP virtual void setThreshold(float threshold) = 0; CV_WRAP virtual void setThreshold(float threshold) = 0;
CV_WRAP virtual Mat getRadiance() const = 0; CV_WRAP virtual Mat getRadiance() const = 0;
}; };
CV_EXPORTS_W Ptr<CalibrateRobertson> createCalibrateRobertson(int max_iter = 30, float threshold = 0.01f); CV_EXPORTS_W Ptr<CalibrateRobertson> createCalibrateRobertson(int max_iter = 30, float threshold = 0.01f);
class CV_EXPORTS_W ExposureMerge : public Algorithm class CV_EXPORTS_W MergeExposures : public Algorithm
{ {
public: public:
CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst,
const std::vector<float>& times, InputArray response) = 0; InputArray times, InputArray response) = 0;
}; };
// "Recovering High Dynamic Range Radiance Maps from Photographs", Debevec, Malik, 1997 // "Recovering High Dynamic Range Radiance Maps from Photographs", Debevec, Malik, 1997
class CV_EXPORTS_W MergeDebevec : public ExposureMerge class CV_EXPORTS_W MergeDebevec : public MergeExposures
{ {
public: public:
CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst,
const std::vector<float>& times, InputArray response) = 0; InputArray times, InputArray response) = 0;
CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, const std::vector<float>& times) = 0; CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, InputArray times) = 0;
}; };
CV_EXPORTS_W Ptr<MergeDebevec> createMergeDebevec(); CV_EXPORTS_W Ptr<MergeDebevec> createMergeDebevec();
// "Exposure Fusion", Mertens et al., 2007 // "Exposure Fusion", Mertens et al., 2007
class CV_EXPORTS_W MergeMertens : public ExposureMerge class CV_EXPORTS_W MergeMertens : public MergeExposures
{ {
public: public:
CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst,
const std::vector<float>& times, InputArray response) = 0; InputArray times, InputArray response) = 0;
CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst) = 0; CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst) = 0;
CV_WRAP virtual float getContrastWeight() const = 0; CV_WRAP virtual float getContrastWeight() const = 0;
...@@ -273,17 +273,17 @@ public: ...@@ -273,17 +273,17 @@ public:
CV_WRAP virtual void setExposureWeight(float exposure_weight) = 0; CV_WRAP virtual void setExposureWeight(float exposure_weight) = 0;
}; };
CV_EXPORTS_W Ptr<MergeMertens> CV_EXPORTS_W Ptr<MergeMertens>
createMergeMertens(float contrast_weight = 1.0f, float saturation_weight = 1.0f, float exposure_weight = 0.0f); createMergeMertens(float contrast_weight = 1.0f, float saturation_weight = 1.0f, float exposure_weight = 0.0f);
// "Dynamic range improvement through multiple exposures", Robertson et al., 1999 // "Dynamic range improvement through multiple exposures", Robertson et al., 1999
class CV_EXPORTS_W MergeRobertson : public ExposureMerge class CV_EXPORTS_W MergeRobertson : public MergeExposures
{ {
public: public:
CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst,
const std::vector<float>& times, InputArray response) = 0; InputArray times, InputArray response) = 0;
CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, const std::vector<float>& times) = 0; CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, InputArray times) = 0;
}; };
CV_EXPORTS_W Ptr<MergeRobertson> createMergeRobertson(); CV_EXPORTS_W Ptr<MergeRobertson> createMergeRobertson();
......
...@@ -50,16 +50,16 @@ namespace cv ...@@ -50,16 +50,16 @@ namespace cv
class AlignMTBImpl : public AlignMTB class AlignMTBImpl : public AlignMTB
{ {
public: public:
AlignMTBImpl(int max_bits, int exclude_range, bool cut) : AlignMTBImpl(int _max_bits, int _exclude_range, bool _cut) :
max_bits(max_bits), name("AlignMTB"),
exclude_range(exclude_range), max_bits(_max_bits),
cut(cut), exclude_range(_exclude_range),
name("AlignMTB") cut(_cut)
{ {
} }
void process(InputArrayOfArrays src, std::vector<Mat>& dst, void process(InputArrayOfArrays src, std::vector<Mat>& dst,
const std::vector<float>& times, InputArray response) InputArray, InputArray)
{ {
process(src, dst); process(src, dst);
} }
...@@ -68,7 +68,7 @@ public: ...@@ -68,7 +68,7 @@ public:
{ {
std::vector<Mat> src; std::vector<Mat> src;
_src.getMatVector(src); _src.getMatVector(src);
checkImageDimensions(src); checkImageDimensions(src);
dst.resize(src.size()); dst.resize(src.size());
...@@ -85,8 +85,7 @@ public: ...@@ -85,8 +85,7 @@ public:
} }
Mat gray; Mat gray;
cvtColor(src[i], gray, COLOR_RGB2GRAY); cvtColor(src[i], gray, COLOR_RGB2GRAY);
Point shift; Point shift = calculateShift(gray_base, gray);
calculateShift(gray_base, gray, shift);
shifts.push_back(shift); shifts.push_back(shift);
shiftMat(src[i], dst[i], shift); shiftMat(src[i], dst[i], shift);
} }
...@@ -113,7 +112,7 @@ public: ...@@ -113,7 +112,7 @@ public:
} }
} }
void calculateShift(InputArray _img0, InputArray _img1, Point& shift) Point calculateShift(InputArray _img0, InputArray _img1)
{ {
Mat img0 = _img0.getMat(); Mat img0 = _img0.getMat();
Mat img1 = _img1.getMat(); Mat img1 = _img1.getMat();
...@@ -126,11 +125,11 @@ public: ...@@ -126,11 +125,11 @@ public:
std::vector<Mat> pyr0; std::vector<Mat> pyr0;
std::vector<Mat> pyr1; std::vector<Mat> pyr1;
buildPyr(img0, pyr0, maxlevel); buildPyr(img0, pyr0, maxlevel);
buildPyr(img1, pyr1, maxlevel); buildPyr(img1, pyr1, maxlevel);
shift = Point(0, 0); Point shift(0, 0);
for(int level = maxlevel; level >= 0; level--) { for(int level = maxlevel; level >= 0; level--) {
shift *= 2; shift *= 2;
Mat tb1, tb2, eb1, eb2; Mat tb1, tb2, eb1, eb2;
computeBitmaps(pyr0[level], tb1, eb1); computeBitmaps(pyr0[level], tb1, eb1);
...@@ -151,14 +150,15 @@ public: ...@@ -151,14 +150,15 @@ public:
if(err < min_err) { if(err < min_err) {
new_shift = test_shift; new_shift = test_shift;
min_err = err; min_err = err;
} }
} }
} }
shift = new_shift; shift = new_shift;
} }
return shift;
} }
void shiftMat(InputArray _src, OutputArray _dst, const Point shift) void shiftMat(InputArray _src, OutputArray _dst, const Point shift)
{ {
Mat src = _src.getMat(); Mat src = _src.getMat();
_dst.create(src.size(), src.type()); _dst.create(src.size(), src.type());
...@@ -186,7 +186,7 @@ public: ...@@ -186,7 +186,7 @@ public:
{ {
fs << "name" << name fs << "name" << name
<< "max_bits" << max_bits << "max_bits" << max_bits
<< "exclude_range" << exclude_range << "exclude_range" << exclude_range
<< "cut" << static_cast<int>(cut); << "cut" << static_cast<int>(cut);
} }
...@@ -197,11 +197,15 @@ public: ...@@ -197,11 +197,15 @@ public:
max_bits = fn["max_bits"]; max_bits = fn["max_bits"];
exclude_range = fn["exclude_range"]; exclude_range = fn["exclude_range"];
int cut_val = fn["cut"]; int cut_val = fn["cut"];
cut = static_cast<bool>(cut_val); cut = (cut_val != 0);
} }
void computeBitmaps(Mat& img, Mat& tb, Mat& eb) void computeBitmaps(InputArray _img, OutputArray _tb, OutputArray _eb)
{ {
Mat img = _img.getMat();
_tb.create(img.size(), CV_8U);
_eb.create(img.size(), CV_8U);
Mat tb = _tb.getMat(), eb = _eb.getMat();
int median = getMedian(img); int median = getMedian(img);
compare(img, median, tb, CMP_GT); compare(img, median, tb, CMP_GT);
compare(abs(img - median), exclude_range, eb, CMP_GT); compare(abs(img - median), exclude_range, eb, CMP_GT);
...@@ -230,7 +234,7 @@ protected: ...@@ -230,7 +234,7 @@ protected:
} }
} }
void buildPyr(Mat& img, std::vector<Mat>& pyr, int maxlevel) void buildPyr(Mat& img, std::vector<Mat>& pyr, int maxlevel)
{ {
pyr.resize(maxlevel + 1); pyr.resize(maxlevel + 1);
pyr[0] = img.clone(); pyr[0] = img.clone();
...@@ -242,7 +246,7 @@ protected: ...@@ -242,7 +246,7 @@ protected:
int getMedian(Mat& img) int getMedian(Mat& img)
{ {
int channels = 0; int channels = 0;
Mat hist; Mat hist;
int hist_size = LDR_SIZE; int hist_size = LDR_SIZE;
float range[] = {0, LDR_SIZE} ; float range[] = {0, LDR_SIZE} ;
const float* ranges[] = {range}; const float* ranges[] = {range};
...@@ -260,8 +264,7 @@ protected: ...@@ -260,8 +264,7 @@ protected:
Ptr<AlignMTB> createAlignMTB(int max_bits, int exclude_range, bool cut) Ptr<AlignMTB> createAlignMTB(int max_bits, int exclude_range, bool cut)
{ {
return new AlignMTBImpl(max_bits, exclude_range, cut); return makePtr<AlignMTBImpl>(max_bits, exclude_range, cut);
} }
} }
...@@ -48,25 +48,26 @@ ...@@ -48,25 +48,26 @@
namespace cv namespace cv
{ {
class CalibrateDebevecImpl : public CalibrateDebevec class CalibrateDebevecImpl : public CalibrateDebevec
{ {
public: public:
CalibrateDebevecImpl(int samples, float lambda, bool random) : CalibrateDebevecImpl(int _samples, float _lambda, bool _random) :
samples(samples),
lambda(lambda),
name("CalibrateDebevec"), name("CalibrateDebevec"),
w(tringleWeights()), samples(_samples),
random(random) lambda(_lambda),
random(_random),
w(tringleWeights())
{ {
} }
void process(InputArrayOfArrays src, OutputArray dst, std::vector<float>& times) void process(InputArrayOfArrays src, OutputArray dst, InputArray _times)
{ {
std::vector<Mat> images; std::vector<Mat> images;
src.getMatVector(images); src.getMatVector(images);
Mat times = _times.getMat();
CV_Assert(images.size() == times.size()); CV_Assert(images.size() == times.total());
checkImageDimensions(images); checkImageDimensions(images);
CV_Assert(images[0].depth() == CV_8U); CV_Assert(images[0].depth() == CV_8U);
...@@ -75,14 +76,14 @@ public: ...@@ -75,14 +76,14 @@ public:
dst.create(LDR_SIZE, 1, CV_32FCC); dst.create(LDR_SIZE, 1, CV_32FCC);
Mat result = dst.getMat(); Mat result = dst.getMat();
std::vector<Point> sample_points; std::vector<Point> sample_points;
if(random) { if(random) {
for(int i = 0; i < samples; i++) { for(int i = 0; i < samples; i++) {
sample_points.push_back(Point(rand() % images[0].cols, rand() % images[0].rows)); sample_points.push_back(Point(rand() % images[0].cols, rand() % images[0].rows));
} }
} else { } else {
int x_points = sqrt(static_cast<double>(samples) * images[0].cols / images[0].rows); int x_points = static_cast<int>(sqrt(static_cast<double>(samples) * images[0].cols / images[0].rows));
int y_points = samples / x_points; int y_points = samples / x_points;
int step_x = images[0].cols / x_points; int step_x = images[0].cols / x_points;
int step_y = images[0].rows / y_points; int step_y = images[0].rows / y_points;
...@@ -106,7 +107,7 @@ public: ...@@ -106,7 +107,7 @@ public:
int val = images[j].ptr()[3*(sample_points[i].y * images[j].cols + sample_points[j].x) + channel]; int val = images[j].ptr()[3*(sample_points[i].y * images[j].cols + sample_points[j].x) + channel];
A.at<float>(eq, val) = w.at<float>(val); A.at<float>(eq, val) = w.at<float>(val);
A.at<float>(eq, LDR_SIZE + i) = -w.at<float>(val); A.at<float>(eq, LDR_SIZE + i) = -w.at<float>(val);
B.at<float>(eq, 0) = w.at<float>(val) * log(times[j]); B.at<float>(eq, 0) = w.at<float>(val) * log(times.at<float>(j));
eq++; eq++;
} }
} }
...@@ -151,7 +152,7 @@ public: ...@@ -151,7 +152,7 @@ public:
samples = fn["samples"]; samples = fn["samples"];
lambda = fn["lambda"]; lambda = fn["lambda"];
int random_val = fn["random"]; int random_val = fn["random"];
random = static_cast<bool>(random_val); random = (random_val != 0);
} }
protected: protected:
...@@ -164,26 +165,27 @@ protected: ...@@ -164,26 +165,27 @@ protected:
Ptr<CalibrateDebevec> createCalibrateDebevec(int samples, float lambda, bool random) Ptr<CalibrateDebevec> createCalibrateDebevec(int samples, float lambda, bool random)
{ {
return new CalibrateDebevecImpl(samples, lambda, random); return makePtr<CalibrateDebevecImpl>(samples, lambda, random);
} }
class CalibrateRobertsonImpl : public CalibrateRobertson class CalibrateRobertsonImpl : public CalibrateRobertson
{ {
public: public:
CalibrateRobertsonImpl(int max_iter, float threshold) : CalibrateRobertsonImpl(int _max_iter, float _threshold) :
max_iter(max_iter),
threshold(threshold),
name("CalibrateRobertson"), name("CalibrateRobertson"),
max_iter(_max_iter),
threshold(_threshold),
weight(RobertsonWeights()) weight(RobertsonWeights())
{ {
} }
void process(InputArrayOfArrays src, OutputArray dst, std::vector<float>& times) void process(InputArrayOfArrays src, OutputArray dst, InputArray _times)
{ {
std::vector<Mat> images; std::vector<Mat> images;
src.getMatVector(images); src.getMatVector(images);
Mat times = _times.getMat();
CV_Assert(images.size() == times.size()); CV_Assert(images.size() == times.total());
checkImageDimensions(images); checkImageDimensions(images);
CV_Assert(images[0].depth() == CV_8U); CV_Assert(images[0].depth() == CV_8U);
...@@ -205,7 +207,7 @@ public: ...@@ -205,7 +207,7 @@ public:
} }
card = 1.0 / card; card = 1.0 / card;
Ptr<MergeRobertson> merge = createMergeRobertson(); Ptr<MergeRobertson> merge = createMergeRobertson();
for(int iter = 0; iter < max_iter; iter++) { for(int iter = 0; iter < max_iter; iter++) {
radiance = Mat::zeros(images[0].size(), CV_32FCC); radiance = Mat::zeros(images[0].size(), CV_32FCC);
...@@ -217,7 +219,7 @@ public: ...@@ -217,7 +219,7 @@ public:
float* rad_ptr = radiance.ptr<float>(); float* rad_ptr = radiance.ptr<float>();
for(size_t pos = 0; pos < images[i].total(); pos++) { for(size_t pos = 0; pos < images[i].total(); pos++) {
for(int c = 0; c < channels; c++, ptr++, rad_ptr++) { for(int c = 0; c < channels; c++, ptr++, rad_ptr++) {
new_response.at<Vec3f>(*ptr)[c] += times[i] * *rad_ptr; new_response.at<Vec3f>(*ptr)[c] += times.at<float>(i) * *rad_ptr;
} }
} }
} }
...@@ -228,7 +230,7 @@ public: ...@@ -228,7 +230,7 @@ public:
new_response.at<Vec3f>(i)[c] /= middle; new_response.at<Vec3f>(i)[c] /= middle;
} }
} }
float diff = sum(sum(abs(new_response - response)))[0] / channels; float diff = static_cast<float>(sum(sum(abs(new_response - response)))[0] / channels);
new_response.copyTo(response); new_response.copyTo(response);
if(diff < threshold) { if(diff < threshold) {
break; break;
...@@ -268,7 +270,7 @@ protected: ...@@ -268,7 +270,7 @@ protected:
Ptr<CalibrateRobertson> createCalibrateRobertson(int max_iter, float threshold) Ptr<CalibrateRobertson> createCalibrateRobertson(int max_iter, float threshold)
{ {
return new CalibrateRobertsonImpl(max_iter, threshold); return makePtr<CalibrateRobertsonImpl>(max_iter, threshold);
} }
} }
\ No newline at end of file
...@@ -97,7 +97,7 @@ Mat linearResponse(int channels) ...@@ -97,7 +97,7 @@ Mat linearResponse(int channels)
{ {
Mat response = Mat(LDR_SIZE, 1, CV_MAKETYPE(CV_32F, channels)); Mat response = Mat(LDR_SIZE, 1, CV_MAKETYPE(CV_32F, channels));
for(int i = 0; i < LDR_SIZE; i++) { for(int i = 0; i < LDR_SIZE; i++) {
response.at<Vec3f>(i) = Vec3f::all(i); response.at<Vec3f>(i) = Vec3f::all(static_cast<float>(i));
} }
return response; return response;
} }
......
...@@ -55,13 +55,14 @@ public: ...@@ -55,13 +55,14 @@ public:
weights(tringleWeights()) weights(tringleWeights())
{ {
} }
void process(InputArrayOfArrays src, OutputArray dst, const std::vector<float>& times, InputArray input_response) void process(InputArrayOfArrays src, OutputArray dst, InputArray _times, InputArray input_response)
{ {
std::vector<Mat> images; std::vector<Mat> images;
src.getMatVector(images); src.getMatVector(images);
Mat times = _times.getMat();
CV_Assert(images.size() == times.size()); CV_Assert(images.size() == times.total());
checkImageDimensions(images); checkImageDimensions(images);
CV_Assert(images[0].depth() == CV_8U); CV_Assert(images[0].depth() == CV_8U);
...@@ -79,12 +80,12 @@ public: ...@@ -79,12 +80,12 @@ public:
response.at<Vec3f>(0) = response.at<Vec3f>(1); response.at<Vec3f>(0) = response.at<Vec3f>(1);
} }
log(response, response); log(response, response);
CV_Assert(response.rows == LDR_SIZE && response.cols == 1 && CV_Assert(response.rows == LDR_SIZE && response.cols == 1 &&
response.channels() == channels); response.channels() == channels);
Mat exp_values(times); Mat exp_values(times);
log(exp_values, exp_values); log(exp_values, exp_values);
result = Mat::zeros(size, CV_32FCC); result = Mat::zeros(size, CV_32FCC);
std::vector<Mat> result_split; std::vector<Mat> result_split;
split(result, result_split); split(result, result_split);
...@@ -117,7 +118,7 @@ public: ...@@ -117,7 +118,7 @@ public:
exp(result, result); exp(result, result);
} }
void process(InputArrayOfArrays src, OutputArray dst, const std::vector<float>& times) void process(InputArrayOfArrays src, OutputArray dst, InputArray times)
{ {
process(src, dst, times, Mat()); process(src, dst, times, Mat());
} }
...@@ -129,21 +130,21 @@ protected: ...@@ -129,21 +130,21 @@ protected:
Ptr<MergeDebevec> createMergeDebevec() Ptr<MergeDebevec> createMergeDebevec()
{ {
return new MergeDebevecImpl; return makePtr<MergeDebevecImpl>();
} }
class MergeMertensImpl : public MergeMertens class MergeMertensImpl : public MergeMertens
{ {
public: public:
MergeMertensImpl(float wcon, float wsat, float wexp) : MergeMertensImpl(float _wcon, float _wsat, float _wexp) :
wcon(wcon), name("MergeMertens"),
wsat(wsat), wcon(_wcon),
wexp(wexp), wsat(_wsat),
name("MergeMertens") wexp(_wexp)
{ {
} }
void process(InputArrayOfArrays src, OutputArrayOfArrays dst, const std::vector<float>& times, InputArray response) void process(InputArrayOfArrays src, OutputArrayOfArrays dst, InputArray, InputArray)
{ {
process(src, dst); process(src, dst);
} }
...@@ -217,7 +218,7 @@ public: ...@@ -217,7 +218,7 @@ public:
weights[i] /= weight_sum; weights[i] /= weight_sum;
Mat img; Mat img;
images[i].convertTo(img, CV_32F, 1.0f/255.0f); images[i].convertTo(img, CV_32F, 1.0f/255.0f);
std::vector<Mat> img_pyr, weight_pyr; std::vector<Mat> img_pyr, weight_pyr;
buildPyramid(img, img_pyr, maxlevel); buildPyramid(img, img_pyr, maxlevel);
buildPyramid(weights[i], weight_pyr, maxlevel); buildPyramid(weights[i], weight_pyr, maxlevel);
...@@ -283,7 +284,7 @@ protected: ...@@ -283,7 +284,7 @@ protected:
Ptr<MergeMertens> createMergeMertens(float wcon, float wsat, float wexp) Ptr<MergeMertens> createMergeMertens(float wcon, float wsat, float wexp)
{ {
return new MergeMertensImpl(wcon, wsat, wexp); return makePtr<MergeMertensImpl>(wcon, wsat, wexp);
} }
class MergeRobertsonImpl : public MergeRobertson class MergeRobertsonImpl : public MergeRobertson
...@@ -294,13 +295,14 @@ public: ...@@ -294,13 +295,14 @@ public:
weight(RobertsonWeights()) weight(RobertsonWeights())
{ {
} }
void process(InputArrayOfArrays src, OutputArray dst, const std::vector<float>& times, InputArray input_response) void process(InputArrayOfArrays src, OutputArray dst, InputArray _times, InputArray input_response)
{ {
std::vector<Mat> images; std::vector<Mat> images;
src.getMatVector(images); src.getMatVector(images);
Mat times = _times.getMat();
CV_Assert(images.size() == times.size()); CV_Assert(images.size() == times.total());
checkImageDimensions(images); checkImageDimensions(images);
CV_Assert(images[0].depth() == CV_8U); CV_Assert(images[0].depth() == CV_8U);
...@@ -312,11 +314,12 @@ public: ...@@ -312,11 +314,12 @@ public:
Mat response = input_response.getMat(); Mat response = input_response.getMat();
if(response.empty()) { if(response.empty()) {
response = linearResponse(channels) / (LDR_SIZE / 2.0f); float middle = LDR_SIZE / 2.0f;
response = linearResponse(channels) / middle;
} }
CV_Assert(response.rows == LDR_SIZE && response.cols == 1 && CV_Assert(response.rows == LDR_SIZE && response.cols == 1 &&
response.channels() == channels); response.channels() == channels);
result = Mat::zeros(images[0].size(), CV_32FCC); result = Mat::zeros(images[0].size(), CV_32FCC);
Mat wsum = Mat::zeros(images[0].size(), CV_32FCC); Mat wsum = Mat::zeros(images[0].size(), CV_32FCC);
for(size_t i = 0; i < images.size(); i++) { for(size_t i = 0; i < images.size(); i++) {
...@@ -324,13 +327,13 @@ public: ...@@ -324,13 +327,13 @@ public:
LUT(images[i], weight, w); LUT(images[i], weight, w);
LUT(images[i], response, im); LUT(images[i], response, im);
result += times[i] * w.mul(im); result += times.at<float>(i) * w.mul(im);
wsum += pow(times[i], 2) * w; wsum += times.at<float>(i) * times.at<float>(i) * w;
} }
result = result.mul(1 / wsum); result = result.mul(1 / wsum);
} }
void process(InputArrayOfArrays src, OutputArray dst, const std::vector<float>& times) void process(InputArrayOfArrays src, OutputArray dst, InputArray times)
{ {
process(src, dst, times, Mat()); process(src, dst, times, Mat());
} }
...@@ -342,7 +345,7 @@ protected: ...@@ -342,7 +345,7 @@ protected:
Ptr<MergeRobertson> createMergeRobertson() Ptr<MergeRobertson> createMergeRobertson()
{ {
return new MergeRobertsonImpl; return makePtr<MergeRobertsonImpl>();
} }
} }
...@@ -50,17 +50,17 @@ namespace cv ...@@ -50,17 +50,17 @@ namespace cv
class TonemapImpl : public Tonemap class TonemapImpl : public Tonemap
{ {
public: public:
TonemapImpl(float gamma) : gamma(gamma), name("Tonemap") TonemapImpl(float _gamma) : name("Tonemap"), gamma(_gamma)
{ {
} }
void process(InputArray _src, OutputArray _dst) void process(InputArray _src, OutputArray _dst)
{ {
Mat src = _src.getMat(); Mat src = _src.getMat();
CV_Assert(!src.empty()); CV_Assert(!src.empty());
_dst.create(src.size(), CV_32FC3); _dst.create(src.size(), CV_32FC3);
Mat dst = _dst.getMat(); Mat dst = _dst.getMat();
double min, max; double min, max;
minMaxLoc(src, &min, &max); minMaxLoc(src, &min, &max);
if(max - min > DBL_EPSILON) { if(max - min > DBL_EPSILON) {
...@@ -95,27 +95,27 @@ protected: ...@@ -95,27 +95,27 @@ protected:
Ptr<Tonemap> createTonemap(float gamma) Ptr<Tonemap> createTonemap(float gamma)
{ {
return new TonemapImpl(gamma); return makePtr<TonemapImpl>(gamma);
} }
class TonemapDragoImpl : public TonemapDrago class TonemapDragoImpl : public TonemapDrago
{ {
public: public:
TonemapDragoImpl(float gamma, float saturation, float bias) : TonemapDragoImpl(float _gamma, float _saturation, float _bias) :
gamma(gamma), name("TonemapDrago"),
saturation(saturation), gamma(_gamma),
bias(bias), saturation(_saturation),
name("TonemapDrago") bias(_bias)
{ {
} }
void process(InputArray _src, OutputArray _dst) void process(InputArray _src, OutputArray _dst)
{ {
Mat src = _src.getMat(); Mat src = _src.getMat();
CV_Assert(!src.empty()); CV_Assert(!src.empty());
_dst.create(src.size(), CV_32FC3); _dst.create(src.size(), CV_32FC3);
Mat img = _dst.getMat(); Mat img = _dst.getMat();
Ptr<Tonemap> linear = createTonemap(1.0f); Ptr<Tonemap> linear = createTonemap(1.0f);
linear->process(src, img); linear->process(src, img);
...@@ -139,7 +139,7 @@ public: ...@@ -139,7 +139,7 @@ public:
div.release(); div.release();
mapLuminance(img, img, gray_img, map, saturation); mapLuminance(img, img, gray_img, map, saturation);
linear->setGamma(gamma); linear->setGamma(gamma);
linear->process(img, img); linear->process(img, img);
} }
...@@ -177,23 +177,23 @@ protected: ...@@ -177,23 +177,23 @@ protected:
Ptr<TonemapDrago> createTonemapDrago(float gamma, float saturation, float bias) Ptr<TonemapDrago> createTonemapDrago(float gamma, float saturation, float bias)
{ {
return new TonemapDragoImpl(gamma, saturation, bias); return makePtr<TonemapDragoImpl>(gamma, saturation, bias);
} }
class TonemapDurandImpl : public TonemapDurand class TonemapDurandImpl : public TonemapDurand
{ {
public: public:
TonemapDurandImpl(float gamma, float contrast, float saturation, float sigma_color, float sigma_space) : TonemapDurandImpl(float _gamma, float _contrast, float _saturation, float _sigma_color, float _sigma_space) :
gamma(gamma), name("TonemapDurand"),
contrast(contrast), gamma(_gamma),
saturation(saturation), contrast(_contrast),
sigma_color(sigma_color), saturation(_saturation),
sigma_space(sigma_space), sigma_color(_sigma_color),
name("TonemapDurand") sigma_space(_sigma_space)
{ {
} }
void process(InputArray _src, OutputArray _dst) void process(InputArray _src, OutputArray _dst)
{ {
Mat src = _src.getMat(); Mat src = _src.getMat();
CV_Assert(!src.empty()); CV_Assert(!src.empty());
...@@ -208,7 +208,7 @@ public: ...@@ -208,7 +208,7 @@ public:
log(gray_img, log_img); log(gray_img, log_img);
Mat map_img; Mat map_img;
bilateralFilter(log_img, map_img, -1, sigma_color, sigma_space); bilateralFilter(log_img, map_img, -1, sigma_color, sigma_space);
double min, max; double min, max;
minMaxLoc(map_img, &min, &max); minMaxLoc(map_img, &min, &max);
float scale = contrast / static_cast<float>(max - min); float scale = contrast / static_cast<float>(max - min);
...@@ -238,8 +238,8 @@ public: ...@@ -238,8 +238,8 @@ public:
{ {
fs << "name" << name fs << "name" << name
<< "gamma" << gamma << "gamma" << gamma
<< "contrast" << contrast << "contrast" << contrast
<< "sigma_color" << sigma_color << "sigma_color" << sigma_color
<< "sigma_space" << sigma_space << "sigma_space" << sigma_space
<< "saturation" << saturation; << "saturation" << saturation;
} }
...@@ -257,23 +257,23 @@ public: ...@@ -257,23 +257,23 @@ public:
protected: protected:
String name; String name;
float gamma, saturation, contrast, sigma_color, sigma_space; float gamma, contrast, saturation, sigma_color, sigma_space;
}; };
Ptr<TonemapDurand> createTonemapDurand(float gamma, float contrast, float saturation, float sigma_color, float sigma_space) Ptr<TonemapDurand> createTonemapDurand(float gamma, float contrast, float saturation, float sigma_color, float sigma_space)
{ {
return new TonemapDurandImpl(gamma, contrast, saturation, sigma_color, sigma_space); return makePtr<TonemapDurandImpl>(gamma, contrast, saturation, sigma_color, sigma_space);
} }
class TonemapReinhardDevlinImpl : public TonemapReinhardDevlin class TonemapReinhardImpl : public TonemapReinhard
{ {
public: public:
TonemapReinhardDevlinImpl(float gamma, float intensity, float light_adapt, float color_adapt) : TonemapReinhardImpl(float _gamma, float _intensity, float _light_adapt, float _color_adapt) :
gamma(gamma), name("TonemapReinhard"),
intensity(intensity), gamma(_gamma),
light_adapt(light_adapt), intensity(_intensity),
color_adapt(color_adapt), light_adapt(_light_adapt),
name("TonemapReinhardDevlin") color_adapt(_color_adapt)
{ {
} }
...@@ -285,7 +285,7 @@ public: ...@@ -285,7 +285,7 @@ public:
Mat img = _dst.getMat(); Mat img = _dst.getMat();
Ptr<Tonemap> linear = createTonemap(1.0f); Ptr<Tonemap> linear = createTonemap(1.0f);
linear->process(src, img); linear->process(src, img);
Mat gray_img; Mat gray_img;
cvtColor(img, gray_img, COLOR_RGB2GRAY); cvtColor(img, gray_img, COLOR_RGB2GRAY);
Mat log_img; Mat log_img;
...@@ -310,11 +310,11 @@ public: ...@@ -310,11 +310,11 @@ public:
Mat adapt = color_adapt * channels[i] + (1.0f - color_adapt) * gray_img; Mat adapt = color_adapt * channels[i] + (1.0f - color_adapt) * gray_img;
adapt = light_adapt * adapt + (1.0f - light_adapt) * global; adapt = light_adapt * adapt + (1.0f - light_adapt) * global;
pow(intensity * adapt, map_key, adapt); pow(intensity * adapt, map_key, adapt);
channels[i] = channels[i].mul(1.0f / (adapt + channels[i])); channels[i] = channels[i].mul(1.0f / (adapt + channels[i]));
} }
gray_img.release(); gray_img.release();
merge(channels, img); merge(channels, img);
linear->setGamma(gamma); linear->setGamma(gamma);
linear->process(img, img); linear->process(img, img);
} }
...@@ -335,8 +335,8 @@ public: ...@@ -335,8 +335,8 @@ public:
{ {
fs << "name" << name fs << "name" << name
<< "gamma" << gamma << "gamma" << gamma
<< "intensity" << intensity << "intensity" << intensity
<< "light_adapt" << light_adapt << "light_adapt" << light_adapt
<< "color_adapt" << color_adapt; << "color_adapt" << color_adapt;
} }
...@@ -355,23 +355,23 @@ protected: ...@@ -355,23 +355,23 @@ protected:
float gamma, intensity, light_adapt, color_adapt; float gamma, intensity, light_adapt, color_adapt;
}; };
Ptr<TonemapReinhardDevlin> createTonemapReinhardDevlin(float gamma, float contrast, float sigma_color, float sigma_space) Ptr<TonemapReinhard> createTonemapReinhard(float gamma, float contrast, float sigma_color, float sigma_space)
{ {
return new TonemapReinhardDevlinImpl(gamma, contrast, sigma_color, sigma_space); return makePtr<TonemapReinhardImpl>(gamma, contrast, sigma_color, sigma_space);
} }
class TonemapMantiukImpl : public TonemapMantiuk class TonemapMantiukImpl : public TonemapMantiuk
{ {
public: public:
TonemapMantiukImpl(float gamma, float scale, float saturation) : TonemapMantiukImpl(float _gamma, float _scale, float _saturation) :
gamma(gamma), name("TonemapMantiuk"),
scale(scale), gamma(_gamma),
saturation(saturation), scale(_scale),
name("TonemapMantiuk") saturation(_saturation)
{ {
} }
void process(InputArray _src, OutputArray _dst) void process(InputArray _src, OutputArray _dst)
{ {
Mat src = _src.getMat(); Mat src = _src.getMat();
CV_Assert(!src.empty()); CV_Assert(!src.empty());
...@@ -389,8 +389,8 @@ public: ...@@ -389,8 +389,8 @@ public:
getContrast(log_img, x_contrast, y_contrast); getContrast(log_img, x_contrast, y_contrast);
for(size_t i = 0; i < x_contrast.size(); i++) { for(size_t i = 0; i < x_contrast.size(); i++) {
mapContrast(x_contrast[i], scale); mapContrast(x_contrast[i]);
mapContrast(y_contrast[i], scale); mapContrast(y_contrast[i]);
} }
Mat right(src.size(), CV_32F); Mat right(src.size(), CV_32F);
...@@ -442,7 +442,7 @@ public: ...@@ -442,7 +442,7 @@ public:
{ {
fs << "name" << name fs << "name" << name
<< "gamma" << gamma << "gamma" << gamma
<< "scale" << scale << "scale" << scale
<< "saturation" << saturation; << "saturation" << saturation;
} }
...@@ -468,7 +468,7 @@ protected: ...@@ -468,7 +468,7 @@ protected:
dst = dst.mul(sign); dst = dst.mul(sign);
} }
void mapContrast(Mat& contrast, float scale) void mapContrast(Mat& contrast)
{ {
const float response_power = 0.4185f; const float response_power = 0.4185f;
signedPow(contrast, response_power, contrast); signedPow(contrast, response_power, contrast);
...@@ -525,7 +525,7 @@ protected: ...@@ -525,7 +525,7 @@ protected:
Ptr<TonemapMantiuk> createTonemapMantiuk(float gamma, float scale, float saturation) Ptr<TonemapMantiuk> createTonemapMantiuk(float gamma, float scale, float saturation)
{ {
return new TonemapMantiukImpl(gamma, scale, saturation); return makePtr<TonemapMantiukImpl>(gamma, scale, saturation);
} }
} }
This diff is collapsed.
...@@ -137,14 +137,16 @@ typedef Ptr<StereoSGBM> Ptr_StereoSGBM; ...@@ -137,14 +137,16 @@ typedef Ptr<StereoSGBM> Ptr_StereoSGBM;
typedef Ptr<Tonemap> Ptr_Tonemap; typedef Ptr<Tonemap> Ptr_Tonemap;
typedef Ptr<TonemapDrago> Ptr_TonemapDrago; typedef Ptr<TonemapDrago> Ptr_TonemapDrago;
typedef Ptr<TonemapReinhardDevlin> Ptr_TonemapReinhardDevlin; typedef Ptr<TonemapReinhard> Ptr_TonemapReinhard;
typedef Ptr<TonemapDurand> Ptr_TonemapDurand; typedef Ptr<TonemapDurand> Ptr_TonemapDurand;
typedef Ptr<TonemapMantiuk> Ptr_TonemapMantiuk; typedef Ptr<TonemapMantiuk> Ptr_TonemapMantiuk;
typedef Ptr<AlignMTB> Ptr_AlignMTB; typedef Ptr<AlignMTB> Ptr_AlignMTB;
typedef Ptr<CalibrateDebevec> Ptr_CalibrateDebevec; typedef Ptr<CalibrateDebevec> Ptr_CalibrateDebevec;
typedef Ptr<CalibrateRobertson> Ptr_CalibrateRobertson; typedef Ptr<CalibrateRobertson> Ptr_CalibrateRobertson;
typedef Ptr<MergeDebevec> Ptr_MergeDebevec; typedef Ptr<MergeDebevec> Ptr_MergeDebevec;
typedef Ptr<MergeRobertson> Ptr_MergeRobertson;
typedef Ptr<MergeMertens> Ptr_MergeMertens; typedef Ptr<MergeMertens> Ptr_MergeMertens;
typedef Ptr<MergeRobertson> Ptr_MergeRobertson;
typedef Ptr<cv::softcascade::ChannelFeatureBuilder> Ptr_ChannelFeatureBuilder; typedef Ptr<cv::softcascade::ChannelFeatureBuilder> Ptr_ChannelFeatureBuilder;
typedef Ptr<CLAHE> Ptr_CLAHE; typedef Ptr<CLAHE> Ptr_CLAHE;
......
...@@ -7,21 +7,9 @@ ...@@ -7,21 +7,9 @@
using namespace cv; using namespace cv;
using namespace std; using namespace std;
void loadExposureSeq(String path, vector<Mat>& images, vector<float>& times) void loadExposureSeq(String, vector<Mat>&, vector<float>&);
{
path += "/";
ifstream list_file((path + "list.txt").c_str());
string name;
float val;
while(list_file >> name >> val) {
Mat img = imread(path + name);
images.push_back(img);
times.push_back(1 / val);
}
list_file.close();
}
int main(int argc, char**argv) int main(int, char**argv)
{ {
vector<Mat> images; vector<Mat> images;
vector<float> times; vector<float> times;
...@@ -38,14 +26,28 @@ int main(int argc, char**argv) ...@@ -38,14 +26,28 @@ int main(int argc, char**argv)
Mat ldr; Mat ldr;
Ptr<TonemapDurand> tonemap = createTonemapDurand(2.2f); Ptr<TonemapDurand> tonemap = createTonemapDurand(2.2f);
tonemap->process(hdr, ldr); tonemap->process(hdr, ldr);
Mat fusion; Mat fusion;
Ptr<MergeMertens> merge_mertens = createMergeMertens(); Ptr<MergeMertens> merge_mertens = createMergeMertens();
merge_mertens->process(images, fusion); merge_mertens->process(images, fusion);
imwrite("fusion.png", fusion * 255); imwrite("fusion.png", fusion * 255);
imwrite("ldr.png", ldr * 255); imwrite("ldr.png", ldr * 255);
imwrite("hdr.hdr", hdr); imwrite("hdr.hdr", hdr);
return 0; return 0;
} }
\ No newline at end of file
void loadExposureSeq(String path, vector<Mat>& images, vector<float>& times)
{
path = path + std::string("/");
ifstream list_file((path + "list.txt").c_str());
string name;
float val;
while(list_file >> name >> val) {
Mat img = imread(path + name);
images.push_back(img);
times.push_back(1 / val);
}
list_file.close();
}
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