Skip to content

Commit 3e41953

Browse files
committed
More convenient VignetteRemover.
1 parent 963b29b commit 3e41953

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

modules/photometric_calib/include/opencv2/photometric_calib/VignetteRemover.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class CV_EXPORTS VignetteRemover
2727
* @param w_ the width of input image
2828
* @param h_ the height of input image
2929
*/
30-
VignetteRemover(const std::string &vignettePath, int w_, int h_);
30+
VignetteRemover(const std::string &vignettePath, const std::string &pcalibPath, int w_, int h_);
3131

3232
~VignetteRemover();
3333

@@ -36,18 +36,19 @@ class CV_EXPORTS VignetteRemover
3636
* @param unGammaImVec the irradiance image.
3737
* @return
3838
*/
39-
Mat getUnVignetteImageMat(std::vector<float> &unGammaImVec);
39+
Mat getUnVignetteImageMat(Mat oriImMat);
4040

4141
/*!
4242
* @brief get vignetting-removed image in form of std::vector<float>.
4343
* @param unGammaImVec the irradiance image.
4444
* @param outImVec the vignetting-removed image vector.
4545
*/
46-
void getUnVignetteImageVec(const std::vector<float> &unGammaImVec, std::vector<float> &outImVec);
46+
void getUnVignetteImageVec(Mat oriImMat, std::vector<float> &outImVec);
4747

4848
private:
4949
float *vignetteMap;
5050
float *vignetteMapInv;
51+
std::string _pcalibPath;
5152
int w, h;
5253
bool validVignette;
5354
};

modules/photometric_calib/src/VignetteRemover.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44

55
#include "precomp.hpp"
66
#include "opencv2/photometric_calib/VignetteRemover.hpp"
7+
#include "opencv2/photometric_calib/GammaRemover.hpp"
78

89
namespace cv {
910
namespace photometric_calib {
1011

11-
VignetteRemover::VignetteRemover(const std::string &vignettePath, int w_, int h_)
12+
VignetteRemover::VignetteRemover(const std::string &vignettePath, const std::string &pcalibPath, int w_, int h_)
1213
{
1314
CV_Assert(vignettePath != "");
15+
CV_Assert(pcalibPath != "");
1416

1517
validVignette = false;
1618
vignetteMap = 0;
@@ -59,24 +61,28 @@ VignetteRemover::VignetteRemover(const std::string &vignettePath, int w_, int h_
5961
vignetteMapInv[i] = 1.0f / vignetteMap[i];
6062
}
6163

64+
_pcalibPath = pcalibPath;
6265
validVignette = true;
6366

6467
}
6568

66-
Mat VignetteRemover::getUnVignetteImageMat(std::vector<float> &unGammaImVec)
69+
Mat VignetteRemover::getUnVignetteImageMat(Mat oriImMat)
6770
{
6871
std::vector<float> _outImVec(w * h);
69-
getUnVignetteImageVec(unGammaImVec, _outImVec);
72+
getUnVignetteImageVec(oriImMat, _outImVec);
7073

7174
Mat _outIm(h, w, CV_32F, &_outImVec[0]);
7275
Mat outIm = _outIm * (1 / 255.0f);
7376
return outIm;
7477
}
7578

76-
void VignetteRemover::getUnVignetteImageVec(const std::vector<float> &unGammaImVec, std::vector<float> &outImVec)
79+
void VignetteRemover::getUnVignetteImageVec(Mat oriImMat, std::vector<float> &outImVec)
7780
{
7881
CV_Assert(validVignette);
7982
CV_Assert(outImVec.size() == (unsigned long) w * h);
83+
photometric_calib::GammaRemover gammaRemover(_pcalibPath, w, h);
84+
std::vector<float> unGammaImVec(w * h);
85+
gammaRemover.getUnGammaImageVec(oriImMat, unGammaImVec);
8086
for (int i = 0; i < w * h; ++i)
8187
{
8288
outImVec[i] = unGammaImVec[i] * vignetteMapInv[i];

0 commit comments

Comments
 (0)