Skip to content

Commit c9ace38

Browse files
f-morozovAlexander Shishkov
authored andcommitted
Docs updated, added InputArray, fixes for makePtr,...
1 parent f99be6b commit c9ace38

22 files changed

Lines changed: 656 additions & 1081 deletions

File tree

doc/mymath.sty

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,3 @@
3939
#7 & #8 & #9
4040
\end{bmatrix}
4141
}
42-

doc/tutorials/bioinspired/retina_model/retina_model.rst~

Lines changed: 0 additions & 418 deletions
This file was deleted.

doc/tutorials/photo/hdr_imaging/hdr_imaging.rst

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ Explanation
4040
loadExposureSeq(argv[1], images, times);
4141
4242
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.
43-
43+
4444
For our image sequence the list is following:
45-
46-
.. code-block:: none
47-
45+
46+
.. code-block:: none
47+
4848
memorial00.png 0.03125
49-
memorial01.png 0.0625
49+
memorial01.png 0.0625
5050
...
5151
memorial15.png 1024
5252
@@ -57,49 +57,49 @@ Explanation
5757
Mat response;
5858
Ptr<CalibrateDebevec> calibrate = createCalibrateDebevec();
5959
calibrate->process(images, response, times);
60-
60+
6161
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.
62-
62+
6363
3. **Make HDR image**
6464

6565
.. code-block:: cpp
6666
6767
Mat hdr;
6868
Ptr<MergeDebevec> merge_debevec = createMergeDebevec();
6969
merge_debevec->process(images, hdr, times, response);
70-
70+
7171
We use Debevec's weighting scheme to construct HDR image using response calculated in the previous item.
72-
72+
7373
4. **Tonemap HDR image**
7474

7575
.. code-block:: cpp
76-
76+
7777
Mat ldr;
7878
Ptr<TonemapDurand> tonemap = createTonemapDurand(2.2f);
7979
tonemap->process(hdr, ldr);
80-
80+
8181
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.
82-
82+
8383
5. **Perform exposure fusion**
8484

8585
.. code-block:: cpp
86-
86+
8787
Mat fusion;
8888
Ptr<MergeMertens> merge_mertens = createMergeMertens();
8989
merge_mertens->process(images, fusion);
9090
9191
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.
92-
92+
9393
6. **Write results**
9494

9595
.. code-block:: cpp
96-
96+
9797
imwrite("fusion.png", fusion * 255);
9898
imwrite("ldr.png", ldr * 255);
9999
imwrite("hdr.hdr", hdr);
100-
100+
101101
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.
102-
102+
103103
Results
104104
=======
105105

@@ -111,7 +111,7 @@ Tonemapped image
111111
:width: 242pt
112112
:alt: Tonemapped image
113113
:align: center
114-
114+
115115
Exposure fusion
116116
------------------
117117

doc/tutorials/tutorials.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ As always, we would be happy to hear your comments and receive your contribution
155155
:height: 80pt
156156
:width: 80pt
157157
:alt: photo Icon
158-
158+
159159
* :ref:`Table-Of-Content-GPU`
160160

161161
.. tabularcolumns:: m{100pt} m{300pt}

modules/highgui/src/grfmt_hdr.cpp

Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ namespace cv
4949

5050
HdrDecoder::HdrDecoder()
5151
{
52-
m_signature = "#?RGBE";
53-
m_signature_alt = "#?RADIANCE";
54-
file = NULL;
55-
m_type = CV_32FC3;
52+
m_signature = "#?RGBE";
53+
m_signature_alt = "#?RADIANCE";
54+
file = NULL;
55+
m_type = CV_32FC3;
5656
}
5757

5858
HdrDecoder::~HdrDecoder()
@@ -61,61 +61,61 @@ HdrDecoder::~HdrDecoder()
6161

6262
size_t HdrDecoder::signatureLength() const
6363
{
64-
return m_signature.size() > m_signature_alt.size() ?
65-
m_signature.size() : m_signature_alt.size();
64+
return m_signature.size() > m_signature_alt.size() ?
65+
m_signature.size() : m_signature_alt.size();
6666
}
6767

6868
bool HdrDecoder::readHeader()
6969
{
70-
file = fopen(m_filename.c_str(), "rb");
71-
if(!file) {
72-
return false;
73-
}
74-
RGBE_ReadHeader(file, &m_width, &m_height, NULL);
75-
if(m_width <= 0 || m_height <= 0) {
76-
fclose(file);
77-
file = NULL;
78-
return false;
79-
}
80-
return true;
70+
file = fopen(m_filename.c_str(), "rb");
71+
if(!file) {
72+
return false;
73+
}
74+
RGBE_ReadHeader(file, &m_width, &m_height, NULL);
75+
if(m_width <= 0 || m_height <= 0) {
76+
fclose(file);
77+
file = NULL;
78+
return false;
79+
}
80+
return true;
8181
}
8282

8383
bool HdrDecoder::readData(Mat& _img)
8484
{
85-
Mat img(m_height, m_width, CV_32FC3);
86-
if(!file) {
87-
if(!readHeader()) {
88-
return false;
89-
}
90-
}
91-
RGBE_ReadPixels_RLE(file, const_cast<float*>(img.ptr<float>()), img.cols, img.rows);
92-
fclose(file); file = NULL;
93-
94-
if(_img.depth() == img.depth()) {
95-
img.convertTo(_img, _img.type());
96-
} else {
97-
img.convertTo(_img, _img.type(), 255);
98-
}
99-
return true;
85+
Mat img(m_height, m_width, CV_32FC3);
86+
if(!file) {
87+
if(!readHeader()) {
88+
return false;
89+
}
90+
}
91+
RGBE_ReadPixels_RLE(file, const_cast<float*>(img.ptr<float>()), img.cols, img.rows);
92+
fclose(file); file = NULL;
93+
94+
if(_img.depth() == img.depth()) {
95+
img.convertTo(_img, _img.type());
96+
} else {
97+
img.convertTo(_img, _img.type(), 255);
98+
}
99+
return true;
100100
}
101101

102102
bool HdrDecoder::checkSignature( const String& signature ) const
103103
{
104-
if(signature.size() >= m_signature.size() &&
105-
(!memcmp(signature.c_str(), m_signature.c_str(), m_signature.size()) ||
106-
!memcmp(signature.c_str(), m_signature_alt.c_str(), m_signature_alt.size())))
107-
return true;
108-
return false;
104+
if(signature.size() >= m_signature.size() &&
105+
(!memcmp(signature.c_str(), m_signature.c_str(), m_signature.size()) ||
106+
!memcmp(signature.c_str(), m_signature_alt.c_str(), m_signature_alt.size())))
107+
return true;
108+
return false;
109109
}
110110

111111
ImageDecoder HdrDecoder::newDecoder() const
112112
{
113-
return new HdrDecoder;
113+
return makePtr<HdrDecoder>();
114114
}
115115

116116
HdrEncoder::HdrEncoder()
117117
{
118-
m_description = "Radiance HDR (*.hdr;*.pic)";
118+
m_description = "Radiance HDR (*.hdr;*.pic)";
119119
}
120120

121121
HdrEncoder::~HdrEncoder()
@@ -124,41 +124,41 @@ HdrEncoder::~HdrEncoder()
124124

125125
bool HdrEncoder::write( const Mat& input_img, const std::vector<int>& params )
126126
{
127-
Mat img;
128-
CV_Assert(input_img.channels() == 3 || input_img.channels() == 1);
129-
if(input_img.channels() == 1) {
130-
std::vector<Mat> splitted(3, input_img);
131-
merge(splitted, img);
132-
} else {
133-
input_img.copyTo(img);
134-
}
135-
if(img.depth() != CV_32F) {
136-
img.convertTo(img, CV_32FC3, 1/255.0f);
137-
}
138-
CV_Assert(params.empty() || params[0] == HDR_NONE || params[0] == HDR_RLE);
139-
FILE *fout = fopen(m_filename.c_str(), "wb");
140-
if(!fout) {
141-
return false;
142-
}
143-
144-
RGBE_WriteHeader(fout, img.cols, img.rows, NULL);
145-
if(params.empty() || params[0] == HDR_RLE) {
146-
RGBE_WritePixels_RLE(fout, const_cast<float*>(img.ptr<float>()), img.cols, img.rows);
147-
} else {
148-
RGBE_WritePixels(fout, const_cast<float*>(img.ptr<float>()), img.cols * img.rows);
149-
}
150-
151-
fclose(fout);
152-
return true;
127+
Mat img;
128+
CV_Assert(input_img.channels() == 3 || input_img.channels() == 1);
129+
if(input_img.channels() == 1) {
130+
std::vector<Mat> splitted(3, input_img);
131+
merge(splitted, img);
132+
} else {
133+
input_img.copyTo(img);
134+
}
135+
if(img.depth() != CV_32F) {
136+
img.convertTo(img, CV_32FC3, 1/255.0f);
137+
}
138+
CV_Assert(params.empty() || params[0] == HDR_NONE || params[0] == HDR_RLE);
139+
FILE *fout = fopen(m_filename.c_str(), "wb");
140+
if(!fout) {
141+
return false;
142+
}
143+
144+
RGBE_WriteHeader(fout, img.cols, img.rows, NULL);
145+
if(params.empty() || params[0] == HDR_RLE) {
146+
RGBE_WritePixels_RLE(fout, const_cast<float*>(img.ptr<float>()), img.cols, img.rows);
147+
} else {
148+
RGBE_WritePixels(fout, const_cast<float*>(img.ptr<float>()), img.cols * img.rows);
149+
}
150+
151+
fclose(fout);
152+
return true;
153153
}
154154

155155
ImageEncoder HdrEncoder::newEncoder() const
156156
{
157-
return new HdrEncoder;
157+
return makePtr<HdrEncoder>();
158158
}
159159

160160
bool HdrEncoder::isFormatSupported( int depth ) const {
161-
return depth != CV_64F;
161+
return depth != CV_64F;
162162
}
163163

164164
}

modules/highgui/src/grfmt_hdr.hpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,29 +58,29 @@ enum HdrCompression
5858
class HdrDecoder : public BaseImageDecoder
5959
{
6060
public:
61-
HdrDecoder();
62-
~HdrDecoder();
63-
bool readHeader();
64-
bool readData( Mat& img );
65-
bool checkSignature( const String& signature ) const;
66-
ImageDecoder newDecoder() const;
67-
size_t signatureLength() const;
61+
HdrDecoder();
62+
~HdrDecoder();
63+
bool readHeader();
64+
bool readData( Mat& img );
65+
bool checkSignature( const String& signature ) const;
66+
ImageDecoder newDecoder() const;
67+
size_t signatureLength() const;
6868
protected:
69-
String m_signature_alt;
70-
FILE *file;
69+
String m_signature_alt;
70+
FILE *file;
7171
};
7272

7373
// ... writer
7474
class HdrEncoder : public BaseImageEncoder
7575
{
7676
public:
77-
HdrEncoder();
78-
~HdrEncoder();
79-
bool write( const Mat& img, const std::vector<int>& params );
80-
ImageEncoder newEncoder() const;
81-
bool isFormatSupported( int depth ) const;
77+
HdrEncoder();
78+
~HdrEncoder();
79+
bool write( const Mat& img, const std::vector<int>& params );
80+
ImageEncoder newEncoder() const;
81+
bool isFormatSupported( int depth ) const;
8282
protected:
83-
83+
8484
};
8585

8686
}

0 commit comments

Comments
 (0)