Commit e6d0b281 authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

Merge pull request #64 from Bellaktris/gsoc

Additions to ximgproc and xphoto modules
parents 286d6ffe cc2353f3
Tracking API ******************************************
============ tracking. Tracking API
******************************************
.. highlight:: cpp .. highlight:: cpp
......
...@@ -50,8 +50,8 @@ StructuredEdgeDetection::detectEdges ...@@ -50,8 +50,8 @@ StructuredEdgeDetection::detectEdges
.. seealso:: .. seealso::
:ocv:class:`Sobel`, :ocv:func:`Sobel`,
:ocv:class:`Canny` :ocv:func:`Canny`
createStructuredEdgeDetection createStructuredEdgeDetection
+++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++
......
...@@ -7,5 +7,5 @@ ximgproc. Extended image processing module. ...@@ -7,5 +7,5 @@ ximgproc. Extended image processing module.
.. toctree:: .. toctree::
:maxdepth: 2 :maxdepth: 2
edge_aware_filters
structured_edge_detection structured_edge_detection
edge_aware_filters
#include "test_precomp.hpp" #include "test_precomp.hpp"
CV_TEST_MAIN("ximpgroc") CV_TEST_MAIN("")
...@@ -5,10 +5,11 @@ namespace cvtest ...@@ -5,10 +5,11 @@ namespace cvtest
TEST(ximpgroc_StructuredEdgeDetection, regression) TEST(ximpgroc_StructuredEdgeDetection, regression)
{ {
cv::String dir = cvtest::TS::ptr()->get_data_path(); cv::String subfolder = "cv/ximgproc/";
cv::String dir = cvtest::TS::ptr()->get_data_path() + subfolder;
int nTests = 12; int nTests = 12;
float threshold = 0.01f; float threshold = 0.01f;
cv::String modelName = dir + "model.yml.gz"; cv::String modelName = dir + "model.yml.gz";
cv::Ptr<cv::ximgproc::StructuredEdgeDetection> pDollar = cv::Ptr<cv::ximgproc::StructuredEdgeDetection> pDollar =
cv::ximgproc::createStructuredEdgeDetection(modelName); cv::ximgproc::createStructuredEdgeDetection(modelName);
...@@ -17,6 +18,7 @@ TEST(ximpgroc_StructuredEdgeDetection, regression) ...@@ -17,6 +18,7 @@ TEST(ximpgroc_StructuredEdgeDetection, regression)
{ {
cv::String srcName = dir + cv::format( "sources/%02d.png", i + 1); cv::String srcName = dir + cv::format( "sources/%02d.png", i + 1);
cv::Mat src = cv::imread( srcName, 1 ); cv::Mat src = cv::imread( srcName, 1 );
ASSERT_TRUE(!src.empty());
cv::String previousResultName = dir + cv::format( "results/%02d.png", i + 1 ); cv::String previousResultName = dir + cv::format( "results/%02d.png", i + 1 );
cv::Mat previousResult = cv::imread( previousResultName, 0 ); cv::Mat previousResult = cv::imread( previousResultName, 0 );
......
...@@ -5,21 +5,18 @@ Automatic white balance correction ...@@ -5,21 +5,18 @@ Automatic white balance correction
balanceWhite balanceWhite
------------ ------------
.. ocv:function:: void balanceWhite(const Mat &src, Mat &dst, const int algorithmType, const float inputMin = 0.0f, const float inputMax = 255.0f, const float outputMin = 0.0f, const float outputMax = 255.0f) .. ocv:function:: void balanceWhite(const Mat &src, Mat &dst, const int algorithmType, const float inputMin = 0.0f, const float inputMax = 255.0f, const float outputMin = 0.0f, const float outputMax = 255.0f)
The function implements different algorithm of automatic white balance, i.e. The function implements different algorithm of automatic white balance, i.e. it tries to map image's white color to perceptual white (this can be violated due to specific illumination or camera settings).
it tries to map image's white color to perceptual white (this can be violated
due to specific illumination or camera settings).
:param src : source image :param algorithmType: type of the algorithm to use. Use WHITE_BALANCE_SIMPLE to perform smart histogram adjustments (ignoring 4% pixels with minimal and maximal values) for each channel.
:param dst : destination image :param inputMin: minimum value in the input image
:param algorithmType : type of the algorithm to use. Use WHITE_BALANCE_SIMPLE to perform smart histogram adjustments (ignoring 4% pixels with minimal and maximal values) for each channel. :param inputMax: maximum value in the input image
:param inputMin : minimum value in the input image :param outputMin: minimum value in the output image
:param inputMax : maximum value in the input image :param outputMax: maximum value in the output image
:param outputMin : minimum value in the output image
:param outputMax : maximum value in the output image
.. seealso:: .. seealso::
:ocv:func:`cvtColor`, :ocv:func:`cvtColor`,
:ocv:func:`equalizeHist` :ocv:func:`equalizeHist`
\ No newline at end of file
...@@ -7,13 +7,13 @@ dctDenoising ...@@ -7,13 +7,13 @@ dctDenoising
------------ ------------
.. ocv:function:: void dctDenoising(const Mat &src, Mat &dst, const float sigma) .. ocv:function:: void dctDenoising(const Mat &src, Mat &dst, const float sigma)
The function implements simple dct-based denoising, The function implements simple dct-based denoising,
link: http://www.ipol.im/pub/art/2011/ys-dct/. link: http://www.ipol.im/pub/art/2011/ys-dct/.
:param src : source image :param src: source image
:param dst : destination image :param dst: destination image
:param sigma : expected noise standard deviation :param sigma: expected noise standard deviation
:param psize : size of block side where dct is computed :param psize: size of block side where dct is computed
.. seealso:: .. seealso::
......
...@@ -7,12 +7,12 @@ Inpainting ...@@ -7,12 +7,12 @@ Inpainting
---------- ----------
.. ocv:function:: void inpaint(const Mat &src, const Mat &mask, Mat &dst, const int algorithmType) .. ocv:function:: void inpaint(const Mat &src, const Mat &mask, Mat &dst, const int algorithmType)
The function implements different single-image inpainting algorithms. The function implements different single-image inpainting algorithms.
:param src : source image, it could be of any type and any number of channels from 1 to 4. In case of 3- and 4-channels images the function expect them in CIELab colorspace or similar one, where first color component shows intensity, while second and third shows colors. Nonetheless you can try any colorspaces. :param src: source image, it could be of any type and any number of channels from 1 to 4. In case of 3- and 4-channels images the function expect them in CIELab colorspace or similar one, where first color component shows intensity, while second and third shows colors. Nonetheless you can try any colorspaces.
:param mask : mask (CV_8UC1), where non-zero pixels indicate valid image area, while zero pixels indicate area to be inpainted :param mask: mask (CV_8UC1), where non-zero pixels indicate valid image area, while zero pixels indicate area to be inpainted
:param dst : destination image :param dst: destination image
:param algorithmType : expected noise standard deviation :param algorithmType: expected noise standard deviation
* INPAINT_SHIFTMAP: This algorithm searches for dominant correspondences (transformations) of image patches and tries to seamlessly fill-in the area to be inpainted using this transformations. Look in the original paper [He2012]_ for details. * INPAINT_SHIFTMAP: This algorithm searches for dominant correspondences (transformations) of image patches and tries to seamlessly fill-in the area to be inpainted using this transformations. Look in the original paper [He2012]_ for details.
.. [He2012] K. He, J. Sun., "Statistics of Patch Offsets for Image Completion", .. [He2012] K. He, J. Sun., "Statistics of Patch Offsets for Image Completion",
......
...@@ -40,11 +40,10 @@ ...@@ -40,11 +40,10 @@
// //
//M*/ //M*/
#ifndef __OPENCV_EDGEDETECTION_HPP__ #ifndef __OPENCV_XPHOTO_HPP__
#define __OPENCV_EDGEDETECTION_HPP__ #define __OPENCV_XPHOTO_HPP__
#include "opencv2/xphoto.hpp" #include "xphoto/inpainting.hpp"
#include "opencv2/xphoto/inpainting.hpp" #include "xphoto/simple_color_balance.hpp"
#include "opencv2/xphoto/simple_color_balance.hpp" #include "xphoto/dct_image_denoising.hpp"
#include "opencv2/xphoto/dct_image_denoising.hpp"
#endif #endif
...@@ -56,6 +56,8 @@ ...@@ -56,6 +56,8 @@
Namespace where all the C++ OpenCV functionality resides Namespace where all the C++ OpenCV functionality resides
*/ */
namespace cv namespace cv
{
namespace xphoto
{ {
/*! This function implements simple dct-based image denoising, /*! This function implements simple dct-based image denoising,
* link: http://www.ipol.im/pub/art/2011/ys-dct/ * link: http://www.ipol.im/pub/art/2011/ys-dct/
...@@ -67,5 +69,6 @@ namespace cv ...@@ -67,5 +69,6 @@ namespace cv
*/ */
CV_EXPORTS_W void dctDenoising(const Mat &src, Mat &dst, const double sigma, const int psize = 16); CV_EXPORTS_W void dctDenoising(const Mat &src, Mat &dst, const double sigma, const int psize = 16);
} }
}
#endif // __OPENCV_DCT_IMAGE_DENOISING_HPP__ #endif // __OPENCV_DCT_IMAGE_DENOISING_HPP__
\ No newline at end of file
...@@ -56,6 +56,8 @@ ...@@ -56,6 +56,8 @@
Namespace where all the C++ OpenCV functionality resides Namespace where all the C++ OpenCV functionality resides
*/ */
namespace cv namespace cv
{
namespace xphoto
{ {
//! various inpainting algorithms //! various inpainting algorithms
enum enum
...@@ -71,5 +73,6 @@ namespace cv ...@@ -71,5 +73,6 @@ namespace cv
*/ */
CV_EXPORTS_W void inpaint(const Mat &src, const Mat &mask, Mat &dst, const int algorithmType); CV_EXPORTS_W void inpaint(const Mat &src, const Mat &mask, Mat &dst, const int algorithmType);
} }
}
#endif // __OPENCV_INPAINTING_HPP__ #endif // __OPENCV_INPAINTING_HPP__
\ No newline at end of file
...@@ -56,6 +56,8 @@ ...@@ -56,6 +56,8 @@
Namespace where all the C++ OpenCV functionality resides Namespace where all the C++ OpenCV functionality resides
*/ */
namespace cv namespace cv
{
namespace xphoto
{ {
//! various white balance algorithms //! various white balance algorithms
enum enum
...@@ -77,5 +79,6 @@ namespace cv ...@@ -77,5 +79,6 @@ namespace cv
const float inputMin = 0.0f, const float inputMax = 255.0f, const float inputMin = 0.0f, const float inputMax = 255.0f,
const float outputMin = 0.0f, const float outputMax = 255.0f); const float outputMin = 0.0f, const float outputMax = 255.0f);
} }
}
#endif // __OPENCV_SIMPLE_COLOR_BALANCE_HPP__ #endif // __OPENCV_SIMPLE_COLOR_BALANCE_HPP__
\ No newline at end of file
...@@ -54,7 +54,7 @@ int main( int argc, const char** argv ) ...@@ -54,7 +54,7 @@ int main( int argc, const char** argv )
psize = 16; psize = 16;
cv::Mat res(src.size(), src.type()); cv::Mat res(src.size(), src.type());
cv::dctDenoising(src, res, sigma, psize); cv::xphoto::dctDenoising(src, res, sigma, psize);
if ( outFilename == "" ) if ( outFilename == "" )
{ {
......
...@@ -56,7 +56,7 @@ int main( int argc, const char** argv ) ...@@ -56,7 +56,7 @@ int main( int argc, const char** argv )
} }
cv::Mat res(src.size(), src.type()); cv::Mat res(src.size(), src.type());
cv::inpaint( src, mask, res, cv::INPAINT_SHIFTMAP ); cv::xphoto::inpaint( src, mask, res, cv::xphoto::INPAINT_SHIFTMAP );
cv::cvtColor(res, res, CV_Lab2RGB); cv::cvtColor(res, res, CV_Lab2RGB);
if ( outFilename == "" ) if ( outFilename == "" )
......
...@@ -44,7 +44,7 @@ int main( int argc, const char** argv ) ...@@ -44,7 +44,7 @@ int main( int argc, const char** argv )
} }
cv::Mat res(src.size(), src.type()); cv::Mat res(src.size(), src.type());
cv::balanceWhite(src, res, cv::WHITE_BALANCE_SIMPLE); cv::xphoto::balanceWhite(src, res, cv::xphoto::WHITE_BALANCE_SIMPLE);
if ( outFilename == "" ) if ( outFilename == "" )
{ {
......
...@@ -54,6 +54,9 @@ ...@@ -54,6 +54,9 @@
namespace cv namespace cv
{ {
namespace xphoto
{
void grayDctDenoising(const Mat &, Mat &, const double, const int); void grayDctDenoising(const Mat &, Mat &, const double, const int);
void rgbDctDenoising(const Mat &, Mat &, const double, const int); void rgbDctDenoising(const Mat &, Mat &, const double, const int);
void dctDenoising(const Mat &, Mat &, const double, const int); void dctDenoising(const Mat &, Mat &, const double, const int);
...@@ -179,3 +182,4 @@ namespace cv ...@@ -179,3 +182,4 @@ namespace cv
} }
} }
}
\ No newline at end of file
...@@ -67,6 +67,9 @@ namespace xphotoInternal ...@@ -67,6 +67,9 @@ namespace xphotoInternal
namespace cv namespace cv
{ {
namespace xphoto
{
template <typename Tp, unsigned int cn> template <typename Tp, unsigned int cn>
static void shiftMapInpaint(const Mat &src, const Mat &mask, Mat &dst, static void shiftMapInpaint(const Mat &src, const Mat &mask, Mat &dst,
const int nTransform = 60, const int psize = 8) const int nTransform = 60, const int psize = 8)
...@@ -117,7 +120,7 @@ namespace cv ...@@ -117,7 +120,7 @@ namespace cv
switch ( algorithmType ) switch ( algorithmType )
{ {
case INPAINT_SHIFTMAP: case xphoto::INPAINT_SHIFTMAP:
shiftMapInpaint <Tp, cn>(src, mask, dst); shiftMapInpaint <Tp, cn>(src, mask, dst);
break; break;
default: default:
...@@ -232,3 +235,4 @@ namespace cv ...@@ -232,3 +235,4 @@ namespace cv
} }
} }
} }
}
...@@ -54,6 +54,9 @@ ...@@ -54,6 +54,9 @@
namespace cv namespace cv
{ {
namespace xphoto
{
template <typename T> template <typename T>
void balanceWhite(std::vector < Mat_<T> > &src, Mat &dst, void balanceWhite(std::vector < Mat_<T> > &src, Mat &dst,
const float inputMin, const float inputMax, const float inputMin, const float inputMax,
...@@ -205,3 +208,4 @@ namespace cv ...@@ -205,3 +208,4 @@ namespace cv
} }
} }
} }
}
...@@ -4,10 +4,11 @@ namespace cvtest ...@@ -4,10 +4,11 @@ namespace cvtest
{ {
TEST(xphoto_dctimagedenoising, regression) TEST(xphoto_dctimagedenoising, regression)
{ {
cv::String dir = cvtest::TS::ptr()->get_data_path() + "dct_image_denoising/"; cv::String subfolder = "cv/xphoto/";
cv::String dir = cvtest::TS::ptr()->get_data_path() + subfolder + "dct_image_denoising/";
int nTests = 1; int nTests = 1;
double thresholds[] = {0.1}; double thresholds[] = {0.2};
int psize[] = {8}; int psize[] = {8};
double sigma[] = {9.0}; double sigma[] = {9.0};
...@@ -16,13 +17,15 @@ namespace cvtest ...@@ -16,13 +17,15 @@ namespace cvtest
{ {
cv::String srcName = dir + cv::format( "sources/%02d.png", i + 1); cv::String srcName = dir + cv::format( "sources/%02d.png", i + 1);
cv::Mat src = cv::imread( srcName, 1 ); cv::Mat src = cv::imread( srcName, 1 );
ASSERT_TRUE(!src.empty());
cv::String previousResultName = dir + cv::format( "results/%02d.png", i + 1 ); cv::String previousResultName = dir + cv::format( "results/%02d.png", i + 1 );
cv::Mat previousResult = cv::imread( previousResultName, 1 ); cv::Mat previousResult = cv::imread( previousResultName, 1 );
ASSERT_TRUE(!src.empty());
cv::Mat currentResult, fastNlMeansResult; cv::Mat currentResult;
cv::dctDenoising(src, currentResult, sigma[i], psize[i]); cv::xphoto::dctDenoising(src, currentResult, sigma[i], psize[i]);
cv::Mat sqrError = ( currentResult - previousResult ) cv::Mat sqrError = ( currentResult - previousResult )
.mul( currentResult - previousResult ); .mul( currentResult - previousResult );
......
...@@ -4,7 +4,8 @@ namespace cvtest ...@@ -4,7 +4,8 @@ namespace cvtest
{ {
TEST(xphoto_simplecolorbalance, regression) TEST(xphoto_simplecolorbalance, regression)
{ {
cv::String dir = cvtest::TS::ptr()->get_data_path() + "simple_white_balance/"; cv::String subfolder = "cv/xphoto/";
cv::String dir = cvtest::TS::ptr()->get_data_path() + subfolder + "simple_white_balance/";
int nTests = 12; int nTests = 12;
float threshold = 0.005f; float threshold = 0.005f;
...@@ -12,12 +13,13 @@ namespace cvtest ...@@ -12,12 +13,13 @@ namespace cvtest
{ {
cv::String srcName = dir + cv::format( "sources/%02d.png", i + 1); cv::String srcName = dir + cv::format( "sources/%02d.png", i + 1);
cv::Mat src = cv::imread( srcName, 1 ); cv::Mat src = cv::imread( srcName, 1 );
ASSERT_TRUE(!src.empty());
cv::String previousResultName = dir + cv::format( "results/%02d.png", i + 1 ); cv::String previousResultName = dir + cv::format( "results/%02d.png", i + 1 );
cv::Mat previousResult = cv::imread( previousResultName, 1 ); cv::Mat previousResult = cv::imread( previousResultName, 1 );
cv::Mat currentResult; cv::Mat currentResult;
cv::balanceWhite(src, currentResult, cv::WHITE_BALANCE_SIMPLE); cv::xphoto::balanceWhite(src, currentResult, cv::xphoto::WHITE_BALANCE_SIMPLE);
cv::Mat sqrError = ( currentResult - previousResult ) cv::Mat sqrError = ( currentResult - previousResult )
.mul( currentResult - previousResult ); .mul( currentResult - previousResult );
......
#include "test_precomp.hpp" #include "test_precomp.hpp"
CV_TEST_MAIN("xphoto") CV_TEST_MAIN("")
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