Commit 932dc223 authored by Manuel Günther's avatar Manuel Günther

Switched to boost::uniform random numbers since boost::normal seems to be buggy.

parent 90133dea
......@@ -236,7 +236,7 @@ static PyGetSetDef PyBobIpBaseGeomNorm_getseters[] = {
static auto process = bob::extension::FunctionDoc(
"process",
"This function geometrically normalizes an image or a position in the image",
"The function rotates and scales the given image, or a position in image coordinates, such that the result is **visually** rotated and scaled with the :py:attr:`rotation_angle` and :py:attr:`scaling_factor`. "
"The function rotates and scales the given image, or a position in image coordinates, such that the result is **visually** rotated and scaled with the :py:attr:`rotation_angle` and :py:attr:`scaling_factor`.\n\n"
".. note:: The :py:func:`__call__` function is an alias for this method.",
true
)
......
......@@ -552,7 +552,11 @@ namespace bob { namespace ip { namespace base {
value = img(valid_y, valid_x);
}
if (random_factor){
value = static_cast<T>(boost::variate_generator<boost::mt19937, boost::normal_distribution<double>>(rng,boost::normal_distribution<double>(1., random_factor))() * value);
// The boost::normal_distribution seems to be unstable.
//double factor = boost::variate_generator<boost::mt19937, boost::normal_distribution<double>>(rng,boost::normal_distribution<double>(1., random_factor))();
// so we use a uniform distribution
double factor = boost::uniform_real<double>(1.-2.*random_factor, 1.+2.*random_factor)(rng);
value = static_cast<T>(factor * value);
}
img(current_pos_y, current_pos_x) = value;
filled_mask(current_pos_y, current_pos_x) = true;
......
......@@ -10,7 +10,6 @@
import math
import numpy
import sys
import nose.tools
from nose.plugins.skip import SkipTest
......@@ -108,11 +107,11 @@ fill_src_image = numpy.array([
fill_src_mask = fill_src_image != 0
fill_ref_image = numpy.array([
[ 246.32156874 , 249.3017102 , 267.47367932 , 250.18328228 , 250.99448144],
[ 130.81580817 , 255. , 255. , 255. , 252.49633169],
[ 56.88830006 , 127. , 127. , 264.01868874 , 132.49000491],
[ 139.74314545 , 63. , 131.18533899 , 130.85030597 , 123.67230802],
[ 134.72139907 , 132.86194994 , 127.25849129 , 134.8082927 , 127.723664 ]
[ 125.57368423 , 117.00587265 , 260.69431128 , 229.86038173 , 230.67618385],
[ 114.31978062 , 255. , 255. , 255. , 275.35599683],
[ 277.36618842 , 127. , 127. , 270.12369219 , 252.23747063],
[ 132.63876879 , 63. , 134.10415134 , 118.95924361 , 248.51244191],
[ 59.14331103 , 64.90119476 , 124.52554278 , 129.64407822 , 246.48701023]
], numpy.float64)
def test_extrapolate_random():
......@@ -127,8 +126,6 @@ def test_extrapolate_random():
image = fill_src_image.astype(numpy.float64)
bob.ip.base.extrapolate_mask(fill_src_mask, image, random_sigma = 0.05, neighbors = 1, rng = bob.core.random.mt19937(42))
if sys.platform == 'darwin':
raise SkipTest("Skipping last test since the RNG seems to generate different sequences on MacOS")
assert numpy.allclose(image, fill_ref_image)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment