Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
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
Commits
06df3836
Commit
06df3836
authored
Apr 12, 2014
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Indent fixes
parent
e032b5f5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
36 deletions
+34
-36
bilateral.cl
modules/imgproc/src/opencl/bilateral.cl
+2
-3
smooth.cpp
modules/imgproc/src/smooth.cpp
+30
-31
test_filters.cpp
modules/imgproc/test/ocl/test_filters.cpp
+2
-2
No files found.
modules/imgproc/src/opencl/bilateral.cl
View file @
06df3836
...
@@ -77,7 +77,7 @@ __kernel void bilateral(__global const uchar * src, int src_step, int src_offset
...
@@ -77,7 +77,7 @@ __kernel void bilateral(__global const uchar * src, int src_step, int src_offset
int_t
val
=
convert_int_t
(
loadpix
(
src
+
src_index
+
space_ofs[k]
))
;
int_t
val
=
convert_int_t
(
loadpix
(
src
+
src_index
+
space_ofs[k]
))
;
uint
diff
=
(
uint
)
SUM
(
abs
(
val
-
val0
))
;
uint
diff
=
(
uint
)
SUM
(
abs
(
val
-
val0
))
;
float
w
=
space_weight[k]
*
native_exp
((
float
)(
diff
*
diff
*
as_float
(
gauss_color_coeff
)))
;
float
w
=
space_weight[k]
*
native_exp
((
float
)(
diff
*
diff
*
as_float
(
gauss_color_coeff
)))
;
sum
+=
convert_float_t
(
val
)
*
(
float_t
)(
w
)
;
sum
+=
convert_float_t
(
val
)
*
(
float_t
)(
w
)
;
wsum
+=
w
;
wsum
+=
w
;
}
}
...
@@ -107,7 +107,7 @@ __kernel void bilateral_float(__global const uchar * src, int src_step, int src_
...
@@ -107,7 +107,7 @@ __kernel void bilateral_float(__global const uchar * src, int src_step, int src_
float_t
val
=
convert_float_t
(
loadpix
(
src
+
src_index
+
space_ofs[k]
))
;
float_t
val
=
convert_float_t
(
loadpix
(
src
+
src_index
+
space_ofs[k]
))
;
float
i
=
SUM
(
fabs
(
val
-
val0
))
;
float
i
=
SUM
(
fabs
(
val
-
val0
))
;
float
w
=
space_weight[k]
*
native_exp
(
i
*
i
*
as_float
(
gauss_color_coeff
))
;
float
w
=
space_weight[k]
*
native_exp
(
i
*
i
*
as_float
(
gauss_color_coeff
))
;
sum
+=
val
*
w
;
sum
+=
val
*
w
;
wsum
+=
w
;
wsum
+=
w
;
}
}
storepix
(
convert_uchar_t
(
sum
/
(
float_t
)(
wsum
))
,
dst
+
dst_index
)
;
storepix
(
convert_uchar_t
(
sum
/
(
float_t
)(
wsum
))
,
dst
+
dst_index
)
;
...
@@ -140,4 +140,3 @@ __kernel void bilateral_float4(__global const uchar * src, int src_step, int src
...
@@ -140,4 +140,3 @@ __kernel void bilateral_float4(__global const uchar * src, int src_step, int src
vstore4
(
convert_uchar4_rtz
(
sum
)
,
0
,
dst
+
dst_index
)
;
vstore4
(
convert_uchar4_rtz
(
sum
)
,
0
,
dst
+
dst_index
)
;
}
}
}
}
modules/imgproc/src/smooth.cpp
View file @
06df3836
...
@@ -2341,50 +2341,49 @@ static bool ocl_bilateralFilter_8u(InputArray _src, OutputArray _dst, int d,
...
@@ -2341,50 +2341,49 @@ static bool ocl_bilateralFilter_8u(InputArray _src, OutputArray _dst, int d,
return
false
;
return
false
;
copyMakeBorder
(
src
,
temp
,
radius
,
radius
,
radius
,
radius
,
borderType
);
copyMakeBorder
(
src
,
temp
,
radius
,
radius
,
radius
,
radius
,
borderType
);
std
::
vector
<
float
>
_space_weight
(
d
*
d
);
std
::
vector
<
float
>
_space_weight
(
d
*
d
);
std
::
vector
<
int
>
_space_ofs
(
d
*
d
);
std
::
vector
<
int
>
_space_ofs
(
d
*
d
);
float
*
const
space_weight
=
&
_space_weight
[
0
];
float
*
const
space_weight
=
&
_space_weight
[
0
];
int
*
const
space_ofs
=
&
_space_ofs
[
0
];
int
*
const
space_ofs
=
&
_space_ofs
[
0
];
// initialize space-related bilateral filter coefficients
// initialize space-related bilateral filter coefficients
for
(
i
=
-
radius
,
maxk
=
0
;
i
<=
radius
;
i
++
)
for
(
i
=
-
radius
,
maxk
=
0
;
i
<=
radius
;
i
++
)
for
(
j
=
-
radius
;
j
<=
radius
;
j
++
)
for
(
j
=
-
radius
;
j
<=
radius
;
j
++
)
{
{
double
r
=
std
::
sqrt
((
double
)
i
*
i
+
(
double
)
j
*
j
);
double
r
=
std
::
sqrt
((
double
)
i
*
i
+
(
double
)
j
*
j
);
if
(
r
>
radius
)
if
(
r
>
radius
)
continue
;
continue
;
space_weight
[
maxk
]
=
(
float
)
std
::
exp
(
r
*
r
*
gauss_space_coeff
);
space_weight
[
maxk
]
=
(
float
)
std
::
exp
(
r
*
r
*
gauss_space_coeff
);
space_ofs
[
maxk
++
]
=
(
int
)(
i
*
temp
.
step
+
j
*
cn
);
space_ofs
[
maxk
++
]
=
(
int
)(
i
*
temp
.
step
+
j
*
cn
);
}
}
char
cvt
[
3
][
40
];
char
cvt
[
3
][
40
];
String
cnstr
=
cn
>
1
?
format
(
"%d"
,
cn
)
:
""
;
String
cnstr
=
cn
>
1
?
format
(
"%d"
,
cn
)
:
""
;
String
kernelName
(
"bilateral"
);
String
kernelName
(
"bilateral"
);
size_t
sizeDiv
=
1
;
size_t
sizeDiv
=
1
;
if
((
ocl
::
Device
::
getDefault
().
isIntel
())
&&
if
((
ocl
::
Device
::
getDefault
().
isIntel
())
&&
(
ocl
::
Device
::
getDefault
().
type
()
==
ocl
::
Device
::
TYPE_GPU
))
(
ocl
::
Device
::
getDefault
().
type
()
==
ocl
::
Device
::
TYPE_GPU
))
{
{
//Intel GPU
//Intel GPU
if
(
dst
.
cols
%
4
==
0
&&
cn
==
1
)
// For single channel x4 sized images.
if
(
dst
.
cols
%
4
==
0
&&
cn
==
1
)
// For single channel x4 sized images.
{
{
kernelName
=
"bilateral_float4"
;
kernelName
=
"bilateral_float4"
;
sizeDiv
=
4
;
sizeDiv
=
4
;
}
}
else
else
{
{
kernelName
=
"bilateral_float"
;
kernelName
=
"bilateral_float"
;
}
}
}
}
ocl
::
Kernel
k
(
kernelName
.
c_str
(),
ocl
::
imgproc
::
bilateral_oclsrc
,
ocl
::
Kernel
k
(
kernelName
.
c_str
(),
ocl
::
imgproc
::
bilateral_oclsrc
,
format
(
"-D radius=%d -D maxk=%d -D cn=%d -D int_t=%s -D uint_t=uint%s -D convert_int_t=%s"
format
(
"-D radius=%d -D maxk=%d -D cn=%d -D int_t=%s -D uint_t=uint%s -D convert_int_t=%s"
" -D uchar_t=%s -D float_t=%s -D convert_float_t=%s -D convert_uchar_t=%s -D gauss_color_coeff=%f"
,
" -D uchar_t=%s -D float_t=%s -D convert_float_t=%s -D convert_uchar_t=%s -D gauss_color_coeff=%f"
,
radius
,
maxk
,
cn
,
ocl
::
typeToStr
(
CV_32SC
(
cn
)),
cnstr
.
c_str
(),
radius
,
maxk
,
cn
,
ocl
::
typeToStr
(
CV_32SC
(
cn
)),
cnstr
.
c_str
(),
ocl
::
convertTypeStr
(
CV_8U
,
CV_32S
,
cn
,
cvt
[
0
]),
ocl
::
convertTypeStr
(
CV_8U
,
CV_32S
,
cn
,
cvt
[
0
]),
ocl
::
typeToStr
(
type
),
ocl
::
typeToStr
(
CV_32FC
(
cn
)),
ocl
::
typeToStr
(
type
),
ocl
::
typeToStr
(
CV_32FC
(
cn
)),
ocl
::
convertTypeStr
(
CV_32S
,
CV_32F
,
cn
,
cvt
[
1
]),
ocl
::
convertTypeStr
(
CV_32S
,
CV_32F
,
cn
,
cvt
[
1
]),
ocl
::
convertTypeStr
(
CV_32F
,
CV_8U
,
cn
,
cvt
[
2
]),
gauss_color_coeff
));
ocl
::
convertTypeStr
(
CV_32F
,
CV_8U
,
cn
,
cvt
[
2
]),
gauss_color_coeff
));
if
(
k
.
empty
())
if
(
k
.
empty
())
return
false
;
return
false
;
...
...
modules/imgproc/test/ocl/test_filters.cpp
View file @
06df3836
...
@@ -373,7 +373,7 @@ OCL_INSTANTIATE_TEST_CASE_P(Filter, Dilate, Combine(
...
@@ -373,7 +373,7 @@ OCL_INSTANTIATE_TEST_CASE_P(Filter, Dilate, Combine(
Values
((
BorderType
)
BORDER_CONSTANT
),
//not used
Values
((
BorderType
)
BORDER_CONSTANT
),
//not used
Values
(
1.0
,
2.0
,
3.0
),
Values
(
1.0
,
2.0
,
3.0
),
Bool
(),
Bool
(),
Values
(
1
)));
//not used
Values
(
1
)));
//not used
OCL_INSTANTIATE_TEST_CASE_P
(
Filter
,
MorphologyEx
,
Combine
(
OCL_INSTANTIATE_TEST_CASE_P
(
Filter
,
MorphologyEx
,
Combine
(
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
,
CV_32FC1
,
CV_32FC3
,
CV_32FC4
,
CV_64FC1
,
CV_64FC4
),
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
,
CV_32FC1
,
CV_32FC3
,
CV_32FC4
,
CV_64FC1
,
CV_64FC4
),
...
@@ -382,7 +382,7 @@ OCL_INSTANTIATE_TEST_CASE_P(Filter, MorphologyEx, Combine(
...
@@ -382,7 +382,7 @@ OCL_INSTANTIATE_TEST_CASE_P(Filter, MorphologyEx, Combine(
Values
((
BorderType
)
BORDER_CONSTANT
),
// not used
Values
((
BorderType
)
BORDER_CONSTANT
),
// not used
Values
(
1.0
,
2.0
,
3.0
),
Values
(
1.0
,
2.0
,
3.0
),
Bool
(),
Bool
(),
Values
(
1
)));
//not used
Values
(
1
)));
//not used
}
}
// namespace cvtest::ocl
}
}
// namespace cvtest::ocl
...
...
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