Exemplo n.º 1
0
"test suite for histogramming implementations"

__author__ = "Jérôme Kieffer"
__contact__ = "*****@*****.**"
__license__ = "GPLv3+"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "2014-09-17"

import unittest
import time
import os
import numpy
import logging
import sys
from utilstest import UtilsTest, Rwp, getLogger
logger = getLogger(__file__)
pyFAI = sys.modules["pyFAI"]
from pyFAI.histogram import histogram, histogram2d
#histogram = sys.modules["pyFAI.histogram"].histogram
#histogram2d = sys.modules["pyFAI.histogram"].histogram2d
if logger.getEffectiveLevel() == logging.DEBUG:
    import pylab
EPS32 = (1.0 + numpy.finfo(numpy.float32).eps)


class test_histogram1d(unittest.TestCase):
    """basic test"""
    shape = (
        512, 512
    )  #(numpy.random.randint(1000, 4000), numpy.random.randint(1000, 4000))
    npt = 500  #numpy.random.randint(1000, 4000)
Exemplo n.º 2
0
#!/usr/bin/python
from utilstest import UtilsTest, getLogger

logger = getLogger(__file__)
import sift
import numpy
import scipy.misc
from math import sin, cos
import pylab
from matplotlib.patches import ConnectionPatch

try:
    import feature
except:
    logger.error("Feature is not available to compare results with C++ implementation")
    feature = None
    res = numpy.empty(0)

img1 = scipy.misc.imread("../../test_match/wiw2.jpg")
img2 = scipy.misc.imread("../../test_match/waldo.jpg")
"""
img1 = scipy.misc.imread("../test_images/fruit_bowl.png")
tmp = scipy.misc.imread("../test_images/banana.png")
img2 = numpy.zeros_like(img1)
img2 = img2 + 255
d0 = (img1.shape[0] - tmp.shape[0])/2
d1 = (img1.shape[1] - tmp.shape[1])/2
img2[d0:-d0,d1:-d1-1] = numpy.copy(tmp)
"""
plan = sift.SiftPlan(template=img1, devicetype="gpu")
kp1 = plan.keypoints(img1)
Exemplo n.º 3
0
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

"""

import sys, os, pyopencl, time
from math import sin, cos
import utilstest
logger = utilstest.getLogger(__file__)
import sift
import numpy
import scipy.misc
import pylab
try:
    import feature
except:
    logger.error("Feature is not available to compare results with C++ implementation")
    feature = None
    res = numpy.empty(0)

def cmp_kp(a, b):
    if a.scale < b.scale:
        return True
    elif a.scale > b.scale:
Exemplo n.º 4
0
#!/usr/bin/python
import sys, os
import utilstest
logger = utilstest.getLogger()
#here = os.path.dirname(os.path.abspath(__file__))
#there = os.path.join(here, "..", "build")
#lib = [os.path.abspath(os.path.join(there, i)) for i in os.listdir(there) if "lib" in i][0]
#sys.path.insert(0, lib)
import sift_pyocl as sift
import numpy
import scipy.misc

#
try:
    lena = scipy.misc.imread(sys.argv[1])
except:
    try:
        import fabio
        lena = fabio.open(sys.argv[1]).data
    except:
        lena = scipy.misc.lena()
        logger.info("Using image lena from scipy")
    else:
        logger.info("Using image %s read with FabIO"%sys.argv[1])
else:
    logger.info("Using image %s read with SciPy"%sys.argv[1])

s = sift.SiftPlan(template=lena, profile=True, context=utilstest.ctx)
kp = s.keypoints(lena)
print kp[:10]
if utilstest.args and not os.path.isfile(utilstest.args[0]):
Exemplo n.º 5
0
from __future__ import absolute_import, division, print_function

import sys, numpy, time
import utilstest
import fabio, pyopencl
from pylab import *
print("#"*50)
pyFAI = sys.modules["pyFAI"]
from pyFAI import splitBBox
from pyFAI import splitBBoxLUT
from pyFAI import splitBBoxCSR
try:
    from pyFAI.third_party import six
except (ImportError, Exception):
    import six
logger = utilstest.getLogger("profile")


ai = pyFAI.load("testimages/Pilatus1M.poni")
data = fabio.open("testimages/Pilatus1M.edf").data
ref = ai.xrpd_LUT(data, 1000)[1]
obt = ai.xrpd_LUT_OCL(data, 1000)[1]
logger.debug("check LUT basics: %s"%abs(obt[1] - ref[1]).max())
assert numpy.allclose(ref,obt)

cyt_lut = pyFAI.splitBBoxLUT.HistoBBox1d(
                 ai._ttha,
                 ai._dttha,
                 bins=1000,
                 unit="2th_deg")
Exemplo n.º 6
0
"""
Created on Fri Mar 07 09:52:51 2014

@author: ashiotis
"""

import sys, numpy, time
import utilstest
import fabio, pyopencl
from pylab import *
print "#"*50
pyFAI = sys.modules["pyFAI"]
from pyFAI import splitBBox
from pyFAI import splitBBoxLUT
from pyFAI import splitBBoxCSR
logger = utilstest.getLogger("profile")


ai = pyFAI.load("testimages/Pilatus1M.poni")
data = fabio.open("testimages/Pilatus1M.edf").data
ref = ai.xrpd_LUT(data, 1000)[1]
obt = ai.xrpd_LUT_OCL(data, 1000)[1]
logger.debug("check LUT basics: %s"%abs(obt[1] - ref[1]).max())
assert numpy.allclose(ref,obt)

cyt_lut = pyFAI.splitBBoxLUT.HistoBBox1d(
                 ai._ttha,
                 ai._dttha,
                 bins=1000,
                 unit="2th_deg")
Exemplo n.º 7
0
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

"""

import sys, os, pyopencl, time
from math import sin, cos
import utilstest
logger = utilstest.getLogger(__file__)
import sift_pyocl as sift
import numpy
import scipy.misc
import pylab
SHOW_FIGURES = False

try:
    import feature
except:
    logger.error(
        "Feature is not available to compare results with C++ implementation")
    feature = None
    res = numpy.empty(0)

Exemplo n.º 8
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
from __future__ import with_statement, print_function

__authors__ = ["Jérôme Kieffer"]
__contact__ = "*****@*****.**"
__license__ = "MIT"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "20140324"
__status__ = "development"

import sys, os, unittest
import utilstest
logger = utilstest.getLogger("test_plugin")
from dahu.plugin import Plugin, plugin_from_function
from dahu.factory import plugin_factory


class TestPlugin(unittest.TestCase):
    def test_plugin(self):
        "Test a stand alone (dummy-) plugin"
        p = Plugin()
        p.setup()
        p.process()
        p.teardown()
        logger.debug(p.output)

    def test_plugin_from_function(self):
        "Test a plugin from a function"
Exemplo n.º 9
0
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

"""

import time, os, logging
import numpy
import pyopencl, pyopencl.array
import scipy, scipy.misc, scipy.ndimage, pylab
import sys
import unittest
from utilstest import UtilsTest, getLogger, ctx
from test_image_functions import *  #for Python implementation of tested functions
from test_image_setup import *
import sift_pyocl as sift
sift_pyocllogger = getLogger(__file__)
if logger.getEffectiveLevel() <= logging.INFO:
    PROFILE = True
    queue = pyopencl.CommandQueue(
        ctx, properties=pyopencl.command_queue_properties.PROFILING_ENABLE)
    import pylab
else:
    PROFILE = False
    queue = pyopencl.CommandQueue(ctx)

SHOW_FIGURES = False
PRINT_KEYPOINTS = False
USE_CPU = False
USE_CPP_SIFT = False  #use reference cplusplus implementation for descriptors comparison... not valid for (octsize,scale)!=(1,1)

print "working on %s" % ctx.devices[0].name
Exemplo n.º 10
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
from __future__ import with_statement, print_function

__authors__ = ["Jérôme Kieffer"]
__contact__ = "*****@*****.**"
__license__ = "MIT"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "02/03/2015"
__status__ = "development"

import sys, os, unittest
import utilstest
logger = utilstest.getLogger("test_job")
import dahu.job


class TestJob(unittest.TestCase):
    def test_plugin_from_function(self):
        self.called = False
        dico = {"plugin_name": "example.square",
                "x": 5}
        j = dahu.job.Job("example.square", dico)
        j.connect_callback(self.callback)
        logger.info(j)
        j.start()
        j.join()
        logger.info(j)
        if "error" in j.output_data:
            logger.error(os.linesep.join(j.output_data["error"]))
Exemplo n.º 11
0
#!/usr/bin/python
import sys, os
import utilstest

logger = utilstest.getLogger()
#here = os.path.dirname(os.path.abspath(__file__))
#there = os.path.join(here, "..", "build")
#lib = [os.path.abspath(os.path.join(there, i)) for i in os.listdir(there) if "lib" in i][0]
#sys.path.insert(0, lib)
import sift_pyocl as sift
import numpy
import scipy.misc

#
try:
    lena = scipy.misc.imread(sys.argv[1])
except:
    try:
        import fabio
        lena = fabio.open(sys.argv[1]).data
    except:
        lena = scipy.misc.lena()
        logger.info("Using image lena from scipy")
    else:
        logger.info("Using image %s read with FabIO" % sys.argv[1])
else:
    logger.info("Using image %s read with SciPy" % sys.argv[1])

s = sift.SiftPlan(template=lena, profile=True, context=utilstest.ctx)
kp = s.keypoints(lena)
print kp[:10]
Exemplo n.º 12
0
#
"""
Test suite for all pyFAI modules.
"""

__authors__ = ["Jérôme Kieffer"]
__contact__ = "*****@*****.**"
__license__ = "GPLv3+"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__data__ = "2014-03-08"

import sys
import unittest

from utilstest import UtilsTest, getLogger
logger = getLogger("test_all")

from test_geometry_refinement  import test_suite_all_GeometryRefinement
from test_azimuthal_integrator import test_suite_all_AzimuthalIntegration
from test_histogram            import test_suite_all_Histogram
from test_peak_picking         import test_suite_all_PeakPicking
from test_geometry             import test_suite_all_Geometry
from test_mask                 import test_suite_all_Mask
from test_openCL               import test_suite_all_OpenCL
from test_export               import test_suite_all_Export
from test_saxs                 import test_suite_all_Saxs
from test_integrate            import test_suite_all_Integrate1d
from test_bilinear             import test_suite_all_bilinear
from test_distortion           import test_suite_all_distortion
from test_flat                 import test_suite_all_Flat
from test_utils                import test_suite_all_Utils
Exemplo n.º 13
0
#
"""
Test suite for all pyFAI modules.
"""

__authors__ = ["Jérôme Kieffer"]
__contact__ = "*****@*****.**"
__license__ = "GPLv3+"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__data__ = "2014-03-08"

import sys
import unittest

from utilstest import UtilsTest, getLogger
logger = getLogger("test_all")

from test_geometry_refinement import test_suite_all_GeometryRefinement
from test_azimuthal_integrator import test_suite_all_AzimuthalIntegration
from test_histogram import test_suite_all_Histogram
from test_peak_picking import test_suite_all_PeakPicking
from test_geometry import test_suite_all_Geometry
from test_mask import test_suite_all_Mask
from test_openCL import test_suite_all_OpenCL
from test_export import test_suite_all_Export
from test_saxs import test_suite_all_Saxs
from test_integrate import test_suite_all_Integrate1d
from test_bilinear import test_suite_all_bilinear
from test_distortion import test_suite_all_distortion
from test_flat import test_suite_all_Flat
from test_utils import test_suite_all_Utils
Exemplo n.º 14
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
from __future__ import with_statement, print_function

__authors__ = ["Jérôme Kieffer"]
__contact__ = "*****@*****.**"
__license__ = "MIT"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "10/06/2016"
__status__ = "development"

import os
import unittest
import utilstest
logger = utilstest.getLogger("test_job")
import dahu.job


class TestJob(unittest.TestCase):
    def test_plugin_from_function(self):
        self.called = False
        dico = {"plugin_name": "example.square",
                "x": 5}
        j = dahu.job.Job("example.square", dico)
        j.connect_callback(self.callback)
        logger.info(j)
        j.start()
        j.join()
        logger.info(j)
        if "error" in j.output_data:
Exemplo n.º 15
0
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

"""

import time, os, logging
import numpy
import pyopencl, pyopencl.array
import scipy, scipy.misc, scipy.ndimage, pylab
import sys
import unittest
from utilstest import UtilsTest, getLogger, ctx
from test_image_functions import * #for Python implementation of tested functions
from test_image_setup import *
import sift_pyocl as sift
sift_pyocllogger = getLogger(__file__)
if logger.getEffectiveLevel() <= logging.INFO:
    PROFILE = True
    queue = pyopencl.CommandQueue(ctx, properties=pyopencl.command_queue_properties.PROFILING_ENABLE)
    import pylab
else:
    PROFILE = False
    queue = pyopencl.CommandQueue(ctx)

SHOW_FIGURES = False
PRINT_KEYPOINTS = False
USE_CPU = False
USE_CPP_SIFT = False #use reference cplusplus implementation for descriptors comparison... not valid for (octsize,scale)!=(1,1)