Skip to content

Commit 76e6ab7

Browse files
committed
comments ilya-lavrenov
1 parent 25ce593 commit 76e6ab7

File tree

3 files changed

+93
-95
lines changed

3 files changed

+93
-95
lines changed

modules/ximgproc/include/opencv2/ximgproc/deriche_filter.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,15 @@ namespace ximgproc {
5151
*
5252
* 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
5353
*
54-
* @param op Source 8-bit or 16bit image, 1-channel or 3-channel image.
54+
* @param _op Source 8-bit or 16bit image, 1-channel or 3-channel image.
55+
* @param _dst result CV_32FC image with same number of channel than _op.
5556
* @param alphaDerive double see paper
5657
* @param alphaMean double see paper
5758
*
5859
* @sa GradientDericheX, GradientDericheY
5960
*/
60-
CV_EXPORTS UMat GradientDericheY(UMat op, double alphaDerive,double alphaMean);
61-
CV_EXPORTS UMat GradientDericheX(UMat op, double alphaDerive,double alphaMean);
61+
CV_EXPORTS void GradientDericheY(InputArray _op, OutputArray _dst, double alphaDerive,double alphaMean);
62+
CV_EXPORTS void GradientDericheX(InputArray _op, OutputArray _dst, double alphaDerive,double alphaMean);
6263

6364
}
6465
}

modules/ximgproc/samples/deriche_demo.cpp

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,17 @@ using namespace cv::ximgproc;
4646
#include <iostream>
4747
using namespace std;
4848

49-
int lowThreshold=20;
50-
int maxThreshold=20;
51-
int const max_lowThreshold = 500;
5249
int alDerive=100;
5350
int alMean=100;
54-
Mat dx, dy;
55-
UMat img;
56-
const char* window_name = "Gradient Modulus";
51+
Mat img;
52+
const string & winName = "Gradient Modulus";
5753

58-
static void DisplayImage(UMat x,string s)
54+
static void DisplayImage(Mat x,string s)
5955
{
6056
vector<Mat> sx;
6157
split(x, sx);
6258
vector<double> minVal(3), maxVal(3);
63-
for (int i = 0; i < static_cast<int>(sx.size()); i++)
59+
for (size_t i = 0; i < sx.size(); i++)
6460
{
6561
minMaxLoc(sx[i], &minVal[i], &maxVal[i]);
6662
}
@@ -78,32 +74,47 @@ static void DisplayImage(UMat x,string s)
7874
*/
7975
static void DericheFilter(int, void*)
8076
{
81-
UMat dst;
77+
Mat dst;
8278
double d=alDerive/100.0,m=alMean/100.0;
83-
UMat rx= GradientDericheX(img,d,m);
84-
UMat ry= GradientDericheY(img,d,m);
79+
Mat rx,ry;
80+
GradientDericheX(img,rx,d,m);
81+
GradientDericheY(img,ry,d,m);
8582
DisplayImage(rx, "Gx");
8683
DisplayImage(ry, "Gy");
8784
add(rx.mul(rx),ry.mul(ry),dst);
8885
sqrt(dst,dst);
89-
DisplayImage(dst, window_name );
86+
DisplayImage(dst, winName );
9087
}
9188

9289

9390
int main(int argc, char* argv[])
9491
{
92+
cv::CommandLineParser parser(argc, argv, "{help h | | show help message}{@input | | input image}");
93+
if (parser.has("help"))
94+
{
95+
parser.printMessage();
96+
return 0;
97+
}
98+
string input_image = parser.get<string>("@input");
99+
if (input_image.empty())
100+
{
101+
parser.printMessage();
102+
parser.printErrors();
103+
return 0;
104+
}
95105
if (argc==2)
96-
imread(argv[1]).copyTo(img);
106+
img = imread(input_image);
97107
if (img.empty())
98108
{
99109
cout << "File not found or empty image\n";
110+
return -1;
100111
}
101112
imshow("Original",img);
102-
namedWindow( window_name, WINDOW_AUTOSIZE );
113+
namedWindow( winName, WINDOW_AUTOSIZE );
103114

104115
/// Create a Trackbar for user to enter threshold
105-
createTrackbar( "Derive:",window_name, &alDerive, 400, DericheFilter );
106-
createTrackbar( "Mean:", window_name, &alMean, 400, DericheFilter );
116+
createTrackbar( "Derive:",winName, &alDerive, 400, DericheFilter );
117+
createTrackbar( "Mean:", winName, &alMean, 400, DericheFilter );
107118
DericheFilter(0,NULL);
108119
waitKey();
109120
return 0;

0 commit comments

Comments
 (0)