Commit 86342522 authored by LaurentBerger's avatar LaurentBerger Committed by Alexander Alekhin

Merge pull request #701 from LaurentBerger:DericheFilter

parent af26ce3a
Extended Image Processing Extended Image Processing
========================= =========================
1. Structured Forests - Structured Forests
2. Domain Transform Filter - Domain Transform Filter
3. Guided Filter - Guided Filter
4. Adaptive Manifold Filter - Adaptive Manifold Filter
5. Joint Bilateral Filter - Joint Bilateral Filter
6. Superpixels - Superpixels
7. Graph segmentation - Graph segmentation
8. Selective search from segmentation - Selective search from segmentation
10. Paillou Filter - Paillou Filter
11. Fast Line Detector - Fast Line Detector
- Deriche Filter
...@@ -76,6 +76,16 @@ ...@@ -76,6 +76,16 @@
publisher={Springer} publisher={Springer}
} }
@article{deriche1987using,
title={Using Canny's criteria to derive a recursively implemented optimal edge detector},
author={Deriche, Rachid},
journal={International journal of computer vision},
volume={1},
number={2},
pages={167--187},
year={1987},
publisher={Springer}
}
@article{uijlings2013selective, @article{uijlings2013selective,
title={Selective search for object recognition}, title={Selective search for object recognition},
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
#include "ximgproc/lsc.hpp" #include "ximgproc/lsc.hpp"
#include "ximgproc/paillou_filter.hpp" #include "ximgproc/paillou_filter.hpp"
#include "ximgproc/fast_line_detector.hpp" #include "ximgproc/fast_line_detector.hpp"
#include "ximgproc/deriche_filter.hpp"
/** @defgroup ximgproc Extended Image Processing /** @defgroup ximgproc Extended Image Processing
@{ @{
......
/*
* By downloading, copying, installing or using the software you agree to this license.
* If you do not agree to this license, do not download, install,
* copy or use the software.
*
*
* License Agreement
* For Open Source Computer Vision Library
* (3 - clause BSD License)
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met :
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and / or other materials provided with the distribution.
*
* * Neither the names of the copyright holders nor the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided by the copyright holders and contributors "as is" and
* any express or implied warranties, including, but not limited to, the implied
* warranties of merchantability and fitness for a particular purpose are disclaimed.
* In no event shall copyright holders or contributors be liable for any direct,
* indirect, incidental, special, exemplary, or consequential damages
* (including, but not limited to, procurement of substitute goods or services;
* loss of use, data, or profits; or business interruption) however caused
* and on any theory of liability, whether in contract, strict liability,
* or tort(including negligence or otherwise) arising in any way out of
* the use of this software, even if advised of the possibility of such damage.
*/
#ifndef __OPENCV_DERICHEFILTER_HPP__
#define __OPENCV_DERICHEFILTER_HPP__
#ifdef __cplusplus
#include <opencv2/core.hpp>
namespace cv {
namespace ximgproc {
//! @addtogroup ximgproc_filters
//! @{
/**
* @brief Applies Y Deriche filter to an image.
*
* For more details about this implementation, please see http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.476.5736&rep=rep1&type=pdf
*
* @param _op Source 8-bit or 16bit image, 1-channel or 3-channel image.
* @param _dst result CV_32FC image with same number of channel than _op.
* @param alphaDerive double see paper
* @param alphaMean double see paper
*
*/
CV_EXPORTS void GradientDericheY(InputArray _op, OutputArray _dst, double alphaDerive,double alphaMean);
/**
* @brief Applies X Deriche filter to an image.
*
* For more details about this implementation, please see http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.476.5736&rep=rep1&type=pdf
*
* @param _op Source 8-bit or 16bit image, 1-channel or 3-channel image.
* @param _dst result CV_32FC image with same number of channel than _op.
* @param alphaDerive double see paper
* @param alphaMean double see paper
*
*/
CV_EXPORTS void GradientDericheX(InputArray _op, OutputArray _dst, double alphaDerive,double alphaMean);
}
}
#endif
#endif
/*
* By downloading, copying, installing or using the software you agree to this license.
* If you do not agree to this license, do not download, install,
* copy or use the software.
*
*
* License Agreement
* For Open Source Computer Vision Library
* (3 - clause BSD License)
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met :
*
* *Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and / or other materials provided with the distribution.
*
* * Neither the names of the copyright holders nor the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided by the copyright holders and contributors "as is" and
* any express or implied warranties, including, but not limited to, the implied
* warranties of merchantability and fitness for a particular purpose are disclaimed.
* In no event shall copyright holders or contributors be liable for any direct,
* indirect, incidental, special, exemplary, or consequential damages
* (including, but not limited to, procurement of substitute goods or services;
* loss of use, data, or profits; or business interruption) however caused
* and on any theory of liability, whether in contract, strict liability,
* or tort(including negligence or otherwise) arising in any way out of
* the use of this software, even if advised of the possibility of such damage.
*/
#include <opencv2/core.hpp>
#include <opencv2/core/utility.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/ximgproc.hpp>
#include "opencv2/ximgproc/deriche_filter.hpp"
using namespace cv;
using namespace cv::ximgproc;
#include <iostream>
using namespace std;
int alDerive=100;
int alMean=100;
Ptr<Mat> img;
const string & winName = "Gradient Modulus";
static void DisplayImage(Mat x,string s)
{
vector<Mat> sx;
split(x, sx);
vector<double> minVal(3), maxVal(3);
for (size_t i = 0; i < sx.size(); i++)
{
minMaxLoc(sx[i], &minVal[i], &maxVal[i]);
}
maxVal[0] = *max_element(maxVal.begin(), maxVal.end());
minVal[0] = *min_element(minVal.begin(), minVal.end());
Mat uc;
x.convertTo(uc, CV_8U,255/(maxVal[0]-minVal[0]),-255*minVal[0]/(maxVal[0]-minVal[0]));
imshow(s, uc);
}
/**
* @function DericheFilter
* @brief Trackbar callback
*/
static void DericheFilter(int, void*)
{
Mat dst;
double d=alDerive/100.0,m=alMean/100.0;
Mat rx,ry;
GradientDericheX(*img.get(),rx,d,m);
GradientDericheY(*img.get(),ry,d,m);
DisplayImage(rx, "Gx");
DisplayImage(ry, "Gy");
add(rx.mul(rx),ry.mul(ry),dst);
sqrt(dst,dst);
DisplayImage(dst, winName );
}
int main(int argc, char* argv[])
{
Mat *m=new Mat;
cv::CommandLineParser parser(argc, argv, "{help h | | show help message}{@input | | input image}");
if (parser.has("help"))
{
parser.printMessage();
return -1;
}
string input_image = parser.get<string>("@input");
if (input_image.empty())
{
parser.printMessage();
parser.printErrors();
return -2;
}
if (argc==2)
*m = imread(input_image);
if (m->empty())
{
cout << "File not found or empty image\n";
return -3;
}
imshow("Original", *m);
img =Ptr<Mat>(m);
namedWindow( winName, WINDOW_AUTOSIZE );
/// Create a Trackbar for user to enter threshold
createTrackbar( "Derive:",winName, &alDerive, 400, DericheFilter );
createTrackbar( "Mean:", winName, &alMean, 400, DericheFilter );
DericheFilter(0,NULL);
waitKey();
return 0;
}
\ No newline at end of file
This diff is collapsed.
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