Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv_contrib
Commits
cd6f7d12
Commit
cd6f7d12
authored
Nov 08, 2018
by
LaurentBerger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rewrite deriche filter- add test - add python wrapper
parent
bd46b032
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
111 additions
and
10 deletions
+111
-10
deriche_filter.hpp
modules/ximgproc/include/opencv2/ximgproc/deriche_filter.hpp
+10
-10
dericheSample.py
modules/ximgproc/samples/dericheSample.py
+60
-0
deriche_filter.cpp
modules/ximgproc/src/deriche_filter.cpp
+0
-0
test_deriche_filter.cpp
modules/ximgproc/test/test_deriche_filter.cpp
+41
-0
No files found.
modules/ximgproc/include/opencv2/ximgproc/deriche_filter.hpp
View file @
cd6f7d12
...
...
@@ -51,25 +51,25 @@ namespace ximgproc {
*
* 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 alpha
Derive
double see paper
* @param
alphaMean
double see paper
* @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 alpha double see paper
* @param
omega
double see paper
*
*/
CV_EXPORTS
void
GradientDericheY
(
InputArray
_op
,
OutputArray
_dst
,
double
alphaDerive
,
double
alphaMean
);
CV_EXPORTS
_W
void
GradientDericheY
(
InputArray
op
,
OutputArray
dst
,
double
alpha
,
double
omega
);
/**
* @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 alpha
Derive
double see paper
* @param
alphaMean
double see paper
* @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 alpha double see paper
* @param
omega
double see paper
*
*/
CV_EXPORTS
void
GradientDericheX
(
InputArray
_op
,
OutputArray
_dst
,
double
alphaDerive
,
double
alphaMean
);
CV_EXPORTS
_W
void
GradientDericheX
(
InputArray
op
,
OutputArray
dst
,
double
alpha
,
double
omega
);
}
}
...
...
modules/ximgproc/samples/dericheSample.py
0 → 100644
View file @
cd6f7d12
import
sys
import
numpy
as
np
import
cv2
as
cv
def
AddSlider
(
sliderName
,
windowName
,
minSlider
,
maxSlider
,
valDefault
,
update
=
[]):
if
update
is
None
:
cv
.
createTrackbar
(
sliderName
,
windowName
,
valDefault
,
maxSlider
-
minSlider
+
1
)
else
:
cv
.
createTrackbar
(
sliderName
,
windowName
,
valDefault
,
maxSlider
-
minSlider
+
1
,
update
)
cv
.
setTrackbarMin
(
sliderName
,
windowName
,
minSlider
)
cv
.
setTrackbarMax
(
sliderName
,
windowName
,
maxSlider
)
cv
.
setTrackbarPos
(
sliderName
,
windowName
,
valDefault
)
class
Filtrage
:
def
__init__
(
self
):
self
.
s
=
0
self
.
alpha
=
100
self
.
omega
=
100
self
.
updateFiltre
=
True
self
.
img
=
[]
self
.
dximg
=
[]
self
.
dyimg
=
[]
self
.
module
=
[]
def
DericheFilter
(
self
):
self
.
dximg
=
cv
.
ximgproc
.
GradientDericheX
(
self
.
img
,
self
.
alpha
/
100.
,
self
.
omega
/
1000.
)
self
.
dyimg
=
cv
.
ximgproc
.
GradientDericheY
(
self
.
img
,
self
.
alpha
/
100.
,
self
.
omega
/
1000.
)
dx2
=
self
.
dximg
*
self
.
dximg
dy2
=
self
.
dyimg
*
self
.
dyimg
self
.
module
=
np
.
sqrt
(
dx2
+
dy2
)
cv
.
normalize
(
src
=
self
.
module
,
dst
=
self
.
module
,
norm_type
=
cv
.
NORM_MINMAX
)
def
SlideBarDeriche
(
self
):
cv
.
destroyWindow
(
self
.
filename
)
cv
.
namedWindow
(
self
.
filename
)
AddSlider
(
"alpha"
,
self
.
filename
,
1
,
400
,
self
.
alpha
,
self
.
UpdateAlpha
)
AddSlider
(
"omega"
,
self
.
filename
,
1
,
1000
,
self
.
omega
,
self
.
UpdateOmega
)
def
UpdateOmega
(
self
,
x
):
self
.
updateFiltre
=
True
self
.
omega
=
x
def
UpdateAlpha
(
self
,
x
):
self
.
updateFiltre
=
True
self
.
alpha
=
x
def
run
(
self
,
argv
):
# Load the source image
self
.
filename
=
argv
[
0
]
if
len
(
argv
)
>
0
else
"../doc/pics/corridor_fld.jpg"
self
.
img
=
cv
.
imread
(
self
.
filename
,
cv
.
IMREAD_GRAYSCALE
)
if
self
.
img
is
None
:
print
(
'cannot read file'
)
return
self
.
SlideBarDeriche
()
while
True
:
cv
.
imshow
(
self
.
filename
,
self
.
img
)
if
self
.
updateFiltre
:
self
.
DericheFilter
()
cv
.
imshow
(
"module"
,
self
.
module
)
self
.
updateFiltre
=
False
code
=
cv
.
waitKey
(
10
)
if
code
==
27
:
break
if
__name__
==
'__main__'
:
Filtrage
()
.
run
(
sys
.
argv
[
1
:])
modules/ximgproc/src/deriche_filter.cpp
View file @
cd6f7d12
This diff is collapsed.
Click to expand it.
modules/ximgproc/test/test_deriche_filter.cpp
0 → 100644
View file @
cd6f7d12
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "test_precomp.hpp"
namespace
opencv_test
{
namespace
{
TEST
(
ximgproc_DericheFilter
,
regression
)
{
Mat
img
=
Mat
::
zeros
(
64
,
64
,
CV_8UC3
);
Mat
res
=
Mat
::
zeros
(
64
,
64
,
CV_32FC3
);
img
.
at
<
Vec3b
>
(
31
,
31
)
=
Vec3b
(
1
,
2
,
4
);
double
a
=
0.5
;
double
w
=
0.0005
;
Mat
dst
;
ximgproc
::
GradientDericheX
(
img
,
dst
,
a
,
w
);
double
c
=
pow
(
1
-
exp
(
-
a
),
2.0
)
*
exp
(
a
);
double
k
=
pow
(
a
*
(
1
-
exp
(
-
a
)),
2.0
)
/
(
1
+
2
*
a
*
exp
(
-
a
)
-
exp
(
-
2
*
a
));
for
(
int
i
=
0
;
i
<
img
.
rows
;
i
++
)
{
double
n
=
-
31
+
i
;
for
(
int
j
=
0
;
j
<
img
.
cols
;
j
++
)
{
double
m
=
-
31
+
j
;
double
x
=
-
c
*
exp
(
-
a
*
fabs
(
m
))
*
sin
(
w
*
m
);
x
=
x
*
(
k
*
(
a
*
sin
(
w
*
fabs
(
n
))
+
w
*
cos
(
w
*
fabs
(
n
)))
*
exp
(
-
a
*
fabs
(
n
)))
/
(
a
*
a
+
w
*
w
);
x
=
x
/
(
w
*
w
);
float
xx
=
static_cast
<
float
>
(
x
);
res
.
at
<
Vec3f
>
(
i
,
j
)
=
Vec3f
(
xx
,
2
*
xx
,
4
*
xx
);
}
}
EXPECT_LE
(
cv
::
norm
(
res
,
dst
,
NORM_INF
),
1e-5
);
Mat
dst2
;
ximgproc
::
GradientDericheY
(
img
,
dst2
,
a
,
w
);
cv
::
transpose
(
dst2
,
dst2
);
EXPECT_LE
(
cv
::
norm
(
dst2
,
dst
,
NORM_INF
),
1e-5
);
}
}
}
// namespace
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment