Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
bob.ip.qualitymeasure
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bob
bob.ip.qualitymeasure
Commits
5f16fde6
Commit
5f16fde6
authored
Jun 28, 2017
by
David GEISSBUHLER
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added modified c++ algorithm
parent
1c6e8ce0
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
611 additions
and
12 deletions
+611
-12
bob/ip/qualitymeasure/__init__.py
bob/ip/qualitymeasure/__init__.py
+1
-0
bob/ip/qualitymeasure/main.cpp
bob/ip/qualitymeasure/main.cpp
+8
-9
bob/ip/qualitymeasure/main_orig.cpp
bob/ip/qualitymeasure/main_orig.cpp
+128
-0
bob/ip/qualitymeasure/script/remove_highlights.py
bob/ip/qualitymeasure/script/remove_highlights.py
+2
-2
bob/ip/qualitymeasure/tan_specular_highlights.cpp
bob/ip/qualitymeasure/tan_specular_highlights.cpp
+457
-0
setup.py
setup.py
+15
-1
No files found.
bob/ip/qualitymeasure/__init__.py
View file @
5f16fde6
...
...
@@ -5,6 +5,7 @@ from .galbally_iqm_features import compute_quality_features
from
.msu_iqa_features
import
compute_msu_iqa_features
from
._library
import
remove_highlights
from
._library_orig
import
remove_highlights_orig
def
get_config
():
...
...
bob/ip/qualitymeasure/main.cpp
View file @
5f16fde6
...
...
@@ -9,13 +9,12 @@
#include <bob.extension/documentation.h>
// declare C++ functions
void
remove_highlights_orig
(
blitz
::
Array
<
float
,
3
>
&
img
,
blitz
::
Array
<
float
,
3
>
&
diff
,
blitz
::
Array
<
float
,
3
>
&
sfi
,
blitz
::
Array
<
float
,
3
>
&
residue
,
float
epsilon
);
// declare C++ function
void
remove_highlights
(
blitz
::
Array
<
float
,
3
>
&
img
,
blitz
::
Array
<
float
,
3
>
&
diff
,
blitz
::
Array
<
float
,
3
>
&
sfi
,
blitz
::
Array
<
float
,
3
>
&
residue
,
float
epsilon
);
// declare the function
static
PyObject
*
PyRemoveHighlights
(
PyObject
*
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
...
...
@@ -26,7 +25,7 @@ static PyObject* PyRemoveHighlights(PyObject*, PyObject* args, PyObject* kwargs)
static
char
**
kwlist
=
const_cast
<
char
**>
(
const_kwlist
);
PyBlitzArrayObject
*
array
;
double
epsilon
=
0.5
f
;
double
epsilon
=
0.5
f
;
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwargs
,
"O&|d"
,
kwlist
,
&
PyBlitzArray_Converter
,
&
array
,
...
...
@@ -55,7 +54,7 @@ static PyObject* PyRemoveHighlights(PyObject*, PyObject* args, PyObject* kwargs)
speckle_img
=
0
;
// call the C++ function
remove_highlights
_orig
(
img
,
diffuse_img
,
speckle_free_img
,
speckle_img
,
(
float
)
epsilon
);
remove_highlights
(
img
,
diffuse_img
,
speckle_free_img
,
speckle_img
,
(
float
)
epsilon
);
// convert the blitz array back to numpy and return it
PyObject
*
ret_tuple
=
PyTuple_New
(
3
);
...
...
bob/ip/qualitymeasure/main_orig.cpp
0 → 100644
View file @
5f16fde6
// include directly and indirectly dependent libraries
#ifdef NO_IMPORT_ARRAY
#undef NO_IMPORT_ARRAY
#endif
#include <bob.blitz/cppapi.h>
#include <bob.blitz/cleanup.h>
#include <bob.extension/documentation.h>
// declare C++ function
void
remove_highlights_orig
(
blitz
::
Array
<
float
,
3
>
&
img
,
blitz
::
Array
<
float
,
3
>
&
diff
,
blitz
::
Array
<
float
,
3
>
&
sfi
,
blitz
::
Array
<
float
,
3
>
&
residue
,
float
epsilon
);
// declare the function
static
PyObject
*
PyRemoveHighlightsOrig
(
PyObject
*
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
BOB_TRY
static
const
char
*
const_kwlist
[]
=
{
"array"
,
"startEps"
,
0
};
static
char
**
kwlist
=
const_cast
<
char
**>
(
const_kwlist
);
PyBlitzArrayObject
*
array
;
double
epsilon
=
0.5
f
;
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwargs
,
"O&|d"
,
kwlist
,
&
PyBlitzArray_Converter
,
&
array
,
&
epsilon
))
return
0
;
// check that the array has the expected properties
if
(
array
->
type_num
!=
NPY_FLOAT32
||
array
->
ndim
!=
3
){
PyErr_Format
(
PyExc_TypeError
,
"remove_highlights : Only 3D arrays of type float32 are allowed"
);
return
0
;
}
// extract the actual blitz array from the Python type
blitz
::
Array
<
float
,
3
>
img
=
*
PyBlitzArrayCxx_AsBlitz
<
float
,
3
>
(
array
);
// results
int
dim_x
=
img
.
shape
()[
2
];
int
dim_y
=
img
.
shape
()[
1
];
blitz
::
Array
<
float
,
3
>
diffuse_img
(
3
,
dim_y
,
dim_x
);
blitz
::
Array
<
float
,
3
>
speckle_free_img
(
3
,
dim_y
,
dim_x
);
blitz
::
Array
<
float
,
3
>
speckle_img
(
3
,
dim_y
,
dim_x
);
diffuse_img
=
0
;
speckle_free_img
=
0
;
speckle_img
=
0
;
// call the C++ function
remove_highlights_orig
(
img
,
diffuse_img
,
speckle_free_img
,
speckle_img
,
(
float
)
epsilon
);
// convert the blitz array back to numpy and return it
PyObject
*
ret_tuple
=
PyTuple_New
(
3
);
PyTuple_SetItem
(
ret_tuple
,
0
,
PyBlitzArrayCxx_AsNumpy
(
speckle_free_img
));
PyTuple_SetItem
(
ret_tuple
,
1
,
PyBlitzArrayCxx_AsNumpy
(
diffuse_img
));
PyTuple_SetItem
(
ret_tuple
,
2
,
PyBlitzArrayCxx_AsNumpy
(
speckle_img
));
return
ret_tuple
;
// handle exceptions that occurred in this function
BOB_CATCH_FUNCTION
(
"remove_highlights_orig"
,
0
)
}
//////////////////////////////////////////////////////////////////////////
/////// Python module declaration ////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// module-wide methods
static
PyMethodDef
module_methods
[]
=
{
{
"remove_highlights_orig"
,
(
PyCFunction
)
PyRemoveHighlightsOrig
,
METH_VARARGS
|
METH_KEYWORDS
,
"remove_highlights [doc]"
},
{
NULL
}
// Sentinel
};
// module documentation
PyDoc_STRVAR
(
module_docstr
,
"Exemplary Python Bindings"
);
// module definition
#if PY_VERSION_HEX >= 0x03000000
static
PyModuleDef
module_definition
=
{
PyModuleDef_HEAD_INIT
,
BOB_EXT_MODULE_NAME
,
module_docstr
,
-
1
,
module_methods
,
0
,
0
,
0
,
0
};
#endif
// create the module
static
PyObject
*
create_module
(
void
)
{
# if PY_VERSION_HEX >= 0x03000000
PyObject
*
module
=
PyModule_Create
(
&
module_definition
);
auto
module_
=
make_xsafe
(
module
);
const
char
*
ret
=
"O"
;
# else
PyObject
*
module
=
Py_InitModule3
(
BOB_EXT_MODULE_NAME
,
module_methods
,
module_docstr
);
const
char
*
ret
=
"N"
;
# endif
if
(
!
module
)
return
0
;
if
(
PyModule_AddStringConstant
(
module
,
"__version__"
,
BOB_EXT_MODULE_VERSION
)
<
0
)
return
0
;
/* imports bob.blitz C-API + dependencies */
if
(
import_bob_blitz
()
<
0
)
return
0
;
return
Py_BuildValue
(
ret
,
module
);
}
PyMODINIT_FUNC
BOB_EXT_ENTRY_NAME
(
void
)
{
# if PY_VERSION_HEX >= 0x03000000
return
# endif
create_module
();
}
bob/ip/qualitymeasure/script/remove_highlights.py
View file @
5f16fde6
...
...
@@ -13,7 +13,7 @@ import argparse
import
bob.io.base
import
numpy
as
np
from
bob.ip.qualitymeasure
import
remove_highlights
from
bob.ip.qualitymeasure
import
remove_highlights
_orig
def
main
(
command_line_parameters
=
None
):
"""Remove the specular component of the input image and write result to
...
...
@@ -51,7 +51,7 @@ def main(command_line_parameters=None):
# 2. compute
print
(
"Extracting diffuse component..."
)
sfi
,
diff
,
residue
=
remove_highlights
(
img
.
astype
(
np
.
float32
),
0.5
)
sfi
,
diff
,
residue
=
remove_highlights
_orig
(
img
.
astype
(
np
.
float32
),
0.5
)
# 1. save output image
print
(
"Saving output file: %s"
%
args
.
outImg
)
...
...
bob/ip/qualitymeasure/tan_specular_highlights.cpp
0 → 100644
View file @
5f16fde6
This diff is collapsed.
Click to expand it.
setup.py
View file @
5f16fde6
...
...
@@ -58,7 +58,7 @@ setup(
# list of files compiled into this extension
[
# the pure C++ code
"bob/ip/qualitymeasure/tan_specular_highlights
_orig
.cpp"
,
"bob/ip/qualitymeasure/tan_specular_highlights.cpp"
,
# the Python bindings
"bob/ip/qualitymeasure/main.cpp"
,
],
...
...
@@ -66,6 +66,20 @@ setup(
version
=
version
,
bob_packages
=
bob_packages
,
),
# The second extension contains the actual C++ code and the Python bindings
Extension
(
"bob.ip.qualitymeasure._library_orig"
,
# list of files compiled into this extension
[
# the pure C++ code
"bob/ip/qualitymeasure/tan_specular_highlights_orig.cpp"
,
# the Python bindings
"bob/ip/qualitymeasure/main_orig.cpp"
,
],
# additional parameters, see Extension documentation
version
=
version
,
bob_packages
=
bob_packages
,
),
],
# Important! We need to tell setuptools that we want the extension to be
...
...
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