tweaked the behaviour of the line noise filter in PDAF mode

This commit is contained in:
Alberto Griggio
2018-03-11 11:48:20 +01:00
parent f4e530f2ac
commit 814a235e9f

View File

@@ -130,8 +130,6 @@ private:
class PDAFLineDenoiseRowFilter: public RawImageSource::CFALineDenoiseRowBlender { class PDAFLineDenoiseRowFilter: public RawImageSource::CFALineDenoiseRowBlender {
static constexpr int BORDER1 = 1;
static constexpr int BORDER2 = 2;
public: public:
PDAFLineDenoiseRowFilter(const std::vector<int> &pattern, int offset): PDAFLineDenoiseRowFilter(const std::vector<int> &pattern, int offset):
pattern_(pattern), pattern_(pattern),
@@ -140,17 +138,24 @@ public:
float operator()(int row) const float operator()(int row) const
{ {
static constexpr float BORDER[] = { 1.f, 1.f, 0.8f, 0.5f, 0.2f };
static constexpr int BORDER_WIDTH = sizeof(BORDER)/sizeof(float) - 1;
if (!pattern_.empty()) { if (!pattern_.empty()) {
int key = (row - offset_) % pattern_.back(); int key = (row - offset_) % pattern_.back();
auto it = std::lower_bound(pattern_.begin(), pattern_.end(), key); auto it = std::lower_bound(pattern_.begin(), pattern_.end(), key);
int d = *it - key;
if (d <= BORDER2) { int b = *it;
return d <= BORDER1 ? 1.f : 0.5f; int d = b - key;
} else if (it > pattern_.begin()) {
d = key - *(it-1); if (it > pattern_.begin()) {
if (d <= BORDER2) { int b2 = *(it-1);
return d <= BORDER1 ? 1.f : 0.5f; int d2 = key - b2;
} float f = BORDER[std::min(std::min(d, d2), BORDER_WIDTH)];
return f;
} else {
float f = BORDER[std::min(d, BORDER_WIDTH)];
return f;
} }
} }
return 0.f; return 0.f;