Пример #1
0
    def test_opencl_implementation(self):
        scikits.image.color.lazyopts.enable()
        colspaces = ['HSV', 'RGB CIE', 'XYZ']
        colfuncs_from = [hsv2rgb, rgbcie2rgb, xyz2rgb]
        colfuncs_to = [rgb2hsv, rgb2rgbcie, rgb2xyz]

        # create an input, and make some promises about it.
        img = lazy.lnumpy.NdarraySymbol.new(value=self.colbars_array)
        img.value = img.value.astype('float32')
        img.contiguous=True
        img.shape = (None, None, 3)
        img.dtype=np.dtype('float32')

        assert_almost_equal(convert_colorspace(self.colbars_array, 'RGB',
                                               'RGB'), self.colbars_array)
        for i, space in enumerate(colspaces):
            print 'test: colorspace', space
            gt = colfuncs_from[i](img)
            eval_gt = lazy.function([img], gt)
            assert_almost_equal(convert_colorspace(self.colbars_array, space,
                                                  'RGB'), eval_gt(img.value))

            gt = colfuncs_to[i](img)
            eval_gt = lazy.function([img], gt)
            #eval_gt.print_eval_order()
            assert_almost_equal(convert_colorspace(self.colbars_array, 'RGB',
                                                   space), eval_gt(img.value))
Пример #2
0
    def test_lazy_convert_colorspace(self):
        colspaces = ['HSV', 'RGB CIE', 'XYZ']
        colfuncs_from = [hsv2rgb, rgbcie2rgb, xyz2rgb]
        colfuncs_to = [rgb2hsv, rgb2rgbcie, rgb2xyz]
        img = lazy.lnumpy.NdarraySymbol.new(value=self.colbars_array)

        assert_almost_equal(convert_colorspace(self.colbars_array, 'RGB',
                                               'RGB'), self.colbars_array)
        for i, space in enumerate(colspaces):
            gt = colfuncs_from[i](img)
            assert_almost_equal(convert_colorspace(self.colbars_array, space,
                                                  'RGB'), gt)

            gt = colfuncs_to[i](img)
            assert_almost_equal(convert_colorspace(self.colbars_array, 'RGB',
                                                   space), gt)

        self.assertRaises(ValueError, convert_colorspace, img, 'nokey', 'XYZ')
        self.assertRaises(ValueError, convert_colorspace, img, 'RGB', 'nokey')
Пример #3
0
    def test_convert_colorspace(self):
        colspaces = ['HSV', 'RGB CIE', 'XYZ']
        colfuncs_from = [hsv2rgb, rgbcie2rgb, xyz2rgb]
        colfuncs_to = [rgb2hsv, rgb2rgbcie, rgb2xyz]

        assert_almost_equal(
            convert_colorspace(self.colbars_array, 'RGB', 'RGB'),
            self.colbars_array)
        for i, space in enumerate(colspaces):
            gt = colfuncs_from[i](self.colbars_array)
            assert_almost_equal(
                convert_colorspace(self.colbars_array, space, 'RGB'), gt)
            gt = colfuncs_to[i](self.colbars_array)
            assert_almost_equal(
                convert_colorspace(self.colbars_array, 'RGB', space), gt)

        self.assertRaises(ValueError, convert_colorspace, self.colbars_array,
                          'nokey', 'XYZ')
        self.assertRaises(ValueError, convert_colorspace, self.colbars_array,
                          'RGB', 'nokey')
Пример #4
0
 def orig_fn():
     return convert_colorspace(imgdata, space, 'RGB')