From eefc851af54e9969aee5192eaed3fe3b3e4150cc Mon Sep 17 00:00:00 2001 From: Andrey Tkachenko Date: Wed, 23 Jul 2014 15:44:35 +0400 Subject: [PATCH] Additional Pixels --- main.cpp | 4 ++-- svkernelv2.cpp | 55 +++++++++++++++++++++++++++++++++----------------- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/main.cpp b/main.cpp index fda8adb..91c4b90 100644 --- a/main.cpp +++ b/main.cpp @@ -15,8 +15,8 @@ int main(int argc, char *argv[]) QQmlApplicationEngine engine; SvImageProvider imageProvider; - QImage imgLeft("../ComputerVision/img/left.png"); - QImage imgRight("../ComputerVision/img/right4.png"); + QImage imgLeft("../CSV/img/left1.png"); + QImage imgRight("../CSV/img/right1.png"); QImage imgStereo(imgLeft.width(), imgLeft.height(), QImage::Format_RGB32); SvImage left(imgLeft); diff --git a/svkernelv2.cpp b/svkernelv2.cpp index b9645b7..c3616e7 100644 --- a/svkernelv2.cpp +++ b/svkernelv2.cpp @@ -24,54 +24,73 @@ int SvKernelV2::rgbDiff(QRgb left, QRgb right) int minDiff= leftDiff < rightDiff ? rightDiff : leftDiff; int diff = cLeft.value() - cRight.value(); - int hsvDiff = abs(cLeft.hsvHue() - cRight.hsvHue()); + int hsvDiff = minDiff > 70 ? abs(cLeft.hsvHue() - cRight.hsvHue()) : 0; if (hsvDiff > 180) { hsvDiff = 360 - hsvDiff; } - return (rightDiff - leftDiff) + diff; /*diff + (minDiff > 20 ? sign(diff) * hsvDiff : 0)*/; + int dsign = sign(diff); + dsign = dsign == 0 ? 1 : dsign; + + return /*dsign * ((rightDiff - leftDiff)>>2) + */diff /*+ (hsvDiff > 5 ? dsign * 10 : 0)*/; } void SvKernelV2::exec(int line) { - QRgb vtop, top, right, bottom, _xy, xy; + QRgb vtop, top, right, bottom, vbottom, _xy, xy; - int dX, _dX, dX_, - dY, _dY, dY_; + int __dX, _dX, dX, dX_, + __dY, _dY, dY, dY_; int value; for (int x = 0; x < m_result->getWidth(); x++) { value = 0; - vtop = m_left->getPixelRGB(x - 1, line - 3); - top = m_left->getPixelRGB(x - 1, line - 2); - right = m_left->getPixelRGB(x, line - 1); - bottom = m_left->getPixelRGB(x - 1, line); - xy = m_left->getPixelRGB(x - 1, line - 1); + vtop = m_left->getPixelRGB(x - 1, line - 3); + top = m_left->getPixelRGB(x - 1, line - 2); + right = m_left->getPixelRGB(x, line - 1); + bottom = m_left->getPixelRGB(x - 1, line); + vbottom = m_left->getPixelRGB(x - 1, line + 1); + xy = m_left->getPixelRGB(x - 1, line - 1); dX_ = rgbDiff(_xy, right); dY_ = rgbDiff(vtop, top); dY = rgbDiff(top, _xy); _dY = rgbDiff(_xy, bottom); + __dY = rgbDiff(bottom, vbottom); - - if ( dX > _dX && dX > dX_ || - dX < _dX && dX < dX_) { - - value += abs(dX); + if ( dX >= _dX && dX > dX_ || + dX <= _dX && dX < dX_) { + if (dX == _dX) { + if (dX > dX_ && _dX > __dX || + dX < dX_ && _dX < __dX) { + value += abs(dX); + } + } else { + value += abs(dX); + } } - if ( dY > _dY && dY > dY_ || - dY < _dY && dY < dY_) { + if ( dY >= _dY && dY > dY_ || + dY <= _dY && dY < dY_) { - value += abs(dY); + if (dY == _dY) { + if (dY > dY_ && _dY > __dY || + dY < dY_ && _dY < __dY) { + + value += abs(dY); + } + } else { + value += abs(dY); + } } if (value > 0) { m_result->putGrayPixel(x - 1, line - 1, value); } + __dX = _dX; _dX = dX; dX = dX_; _xy = right;