Skip to content

Commit 986a283

Browse files
committed
Merge pull request #702 from LaurentBerger:PaillouFilter
2 parents 55e119c + 42640a3 commit 986a283

File tree

6 files changed

+673
-0
lines changed

6 files changed

+673
-0
lines changed

modules/ximgproc/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ Extended Image Processing
99
6. Superpixels
1010
7. Graph segmentation
1111
8. Selective search from segmentation
12+
10. Paillou Filter

modules/ximgproc/doc/ximgproc.bib

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,13 @@ @inproceedings{zhang2014100+
166166
year={2014},
167167
organization={IEEE}
168168
}
169+
170+
@article{paillou1997detecting,
171+
title={Detecting step edges in noisy SAR images: a new linear operator},
172+
author={Paillou, Philippe},
173+
journal={IEEE transactions on geoscience and remote sensing},
174+
volume={35},
175+
number={1},
176+
pages={191--196},
177+
year={1997}
178+
}

modules/ximgproc/include/opencv2/ximgproc.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
#include "ximgproc/weighted_median_filter.hpp"
4949
#include "ximgproc/slic.hpp"
5050
#include "ximgproc/lsc.hpp"
51+
#include "ximgproc/paillou_filter.hpp"
52+
5153

5254
/** @defgroup ximgproc Extended Image Processing
5355
@{
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* By downloading, copying, installing or using the software you agree to this license.
3+
* If you do not agree to this license, do not download, install,
4+
* copy or use the software.
5+
*
6+
*
7+
* License Agreement
8+
* For Open Source Computer Vision Library
9+
* (3 - clause BSD License)
10+
*
11+
* Redistribution and use in source and binary forms, with or without modification,
12+
* are permitted provided that the following conditions are met :
13+
*
14+
* *Redistributions of source code must retain the above copyright notice,
15+
* this list of conditions and the following disclaimer.
16+
*
17+
* * Redistributions in binary form must reproduce the above copyright notice,
18+
* this list of conditions and the following disclaimer in the documentation
19+
* and / or other materials provided with the distribution.
20+
*
21+
* * Neither the names of the copyright holders nor the names of the contributors
22+
* may be used to endorse or promote products derived from this software
23+
* without specific prior written permission.
24+
*
25+
* This software is provided by the copyright holders and contributors "as is" and
26+
* any express or implied warranties, including, but not limited to, the implied
27+
* warranties of merchantability and fitness for a particular purpose are disclaimed.
28+
* In no event shall copyright holders or contributors be liable for any direct,
29+
* indirect, incidental, special, exemplary, or consequential damages
30+
* (including, but not limited to, procurement of substitute goods or services;
31+
* loss of use, data, or profits; or business interruption) however caused
32+
* and on any theory of liability, whether in contract, strict liability,
33+
* or tort(including negligence or otherwise) arising in any way out of
34+
* the use of this software, even if advised of the possibility of such damage.
35+
*/
36+
37+
#ifndef __OPENCV_PAILLOUFILTER_HPP__
38+
#define __OPENCV_PAILLOUFILTER_HPP__
39+
#ifdef __cplusplus
40+
41+
#include <opencv2/core.hpp>
42+
43+
namespace cv {
44+
namespace ximgproc {
45+
46+
//! @addtogroup ximgproc_filters
47+
//! @{
48+
49+
/**
50+
* @brief Applies Paillou filter to an image.
51+
*
52+
* For more details about this implementation, please see @cite paillou1997detecting
53+
*
54+
* @param op Source 8-bit or 16bit image, 1-channel or 3-channel image.
55+
* @param _dst result CV_32F image with same numeber of channel than op.
56+
* @param omega double see paper
57+
* @param alpha double see paper
58+
*
59+
* @sa GradientPaillouX, GradientPaillouY
60+
*/
61+
CV_EXPORTS void GradientPaillouY(InputArray op, OutputArray _dst, double alpha, double omega);
62+
CV_EXPORTS void GradientPaillouX(InputArray op, OutputArray _dst, double alpha, double omega);
63+
64+
}
65+
}
66+
#endif
67+
#endif
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/*
2+
* By downloading, copying, installing or using the software you agree to this license.
3+
* If you do not agree to this license, do not download, install,
4+
* copy or use the software.
5+
*
6+
*
7+
* License Agreement
8+
* For Open Source Computer Vision Library
9+
* (3 - clause BSD License)
10+
*
11+
* Redistribution and use in source and binary forms, with or without modification,
12+
* are permitted provided that the following conditions are met :
13+
*
14+
* *Redistributions of source code must retain the above copyright notice,
15+
* this list of conditions and the following disclaimer.
16+
*
17+
* * Redistributions in binary form must reproduce the above copyright notice,
18+
* this list of conditions and the following disclaimer in the documentation
19+
* and / or other materials provided with the distribution.
20+
*
21+
* * Neither the names of the copyright holders nor the names of the contributors
22+
* may be used to endorse or promote products derived from this software
23+
* without specific prior written permission.
24+
*
25+
* This software is provided by the copyright holders and contributors "as is" and
26+
* any express or implied warranties, including, but not limited to, the implied
27+
* warranties of merchantability and fitness for a particular purpose are disclaimed.
28+
* In no event shall copyright holders or contributors be liable for any direct,
29+
* indirect, incidental, special, exemplary, or consequential damages
30+
* (including, but not limited to, procurement of substitute goods or services;
31+
* loss of use, data, or profits; or business interruption) however caused
32+
* and on any theory of liability, whether in contract, strict liability,
33+
* or tort(including negligence or otherwise) arising in any way out of
34+
* the use of this software, even if advised of the possibility of such damage.
35+
*/
36+
37+
#include <opencv2/core.hpp>
38+
#include <opencv2/core/utility.hpp>
39+
#include <opencv2/highgui.hpp>
40+
#include <opencv2/ximgproc.hpp>
41+
#include "opencv2/ximgproc/paillou_filter.hpp"
42+
43+
using namespace cv;
44+
using namespace cv::ximgproc;
45+
46+
#include <iostream>
47+
using namespace std;
48+
49+
int aa = 100, ww = 10;
50+
Mat dx, dy;
51+
UMat img;
52+
const char* window_name = "Gradient Modulus";
53+
54+
static void DisplayImage(Mat x,string s)
55+
{
56+
vector<Mat> sx;
57+
split(x, sx);
58+
vector<double> minVal(3), maxVal(3);
59+
for (int i = 0; i < static_cast<int>(sx.size()); i++)
60+
{
61+
minMaxLoc(sx[i], &minVal[i], &maxVal[i]);
62+
}
63+
maxVal[0] = *max_element(maxVal.begin(), maxVal.end());
64+
minVal[0] = *min_element(minVal.begin(), minVal.end());
65+
Mat uc;
66+
x.convertTo(uc, CV_8U,255/(maxVal[0]-minVal[0]),-255*minVal[0]/(maxVal[0]-minVal[0]));
67+
imshow(s, uc);
68+
}
69+
70+
71+
/**
72+
* @function paillouFilter
73+
* @brief Trackbar callback
74+
*/
75+
static void PaillouFilter(int, void*)
76+
{
77+
Mat dst;
78+
double a=aa/100.0,w=ww/100.0;
79+
Mat rx,ry;
80+
GradientPaillouX(img,rx,a,w);
81+
GradientPaillouY(img,ry,a,w);
82+
DisplayImage(rx, "Gx");
83+
DisplayImage(ry, "Gy");
84+
add(rx.mul(rx),ry.mul(ry),dst);
85+
sqrt(dst,dst);
86+
DisplayImage(dst, window_name );
87+
}
88+
89+
90+
int main(int argc, char* argv[])
91+
{
92+
if (argc==2)
93+
imread(argv[1]).copyTo(img);
94+
if (img.empty())
95+
{
96+
cout << "File not found or empty image\n";
97+
}
98+
imshow("Original",img);
99+
namedWindow( window_name, WINDOW_AUTOSIZE );
100+
101+
/// Create a Trackbar for user to enter threshold
102+
createTrackbar( "a:",window_name, &aa, 400, PaillouFilter );
103+
createTrackbar( "w:", window_name, &ww, 400, PaillouFilter );
104+
PaillouFilter(0,NULL);
105+
waitKey();
106+
return 0;
107+
}

0 commit comments

Comments
 (0)