コード例 #1
0
 def _build_color_transform(self):
     # this first line should be the only difference from the same method in base Image
     if len(self.tile_shape) == 2 or self.tile_shape[2] == 1:
         # luminance data
         fclim = Function(self._func_templates['clim_float'])
         fgamma = Function(self._func_templates['gamma_float'])
         # NOTE: red_to_luminance only uses the red component, fancy internalformats
         #   may need to use the other components or a different function chain
         fun = FunctionChain(
             None,
             [
                 Function(self._func_templates['red_to_luminance']),
                 fclim,
                 fgamma,
                 Function(self.cmap.glsl_map),
             ],
         )
     else:
         # RGB/A image data (no colormap)
         fclim = Function(self._func_templates['clim'])
         fgamma = Function(self._func_templates['gamma'])
         fun = FunctionChain(
             None,
             [
                 Function(self._func_templates['null_color_transform']),
                 fclim,
                 fgamma,
             ],
         )
     fclim['clim'] = self._texture.clim_normalized
     fgamma['gamma'] = self.gamma
     return fun
コード例 #2
0
ファイル: image.py プロジェクト: zeroth/napari
def _build_color_transform(data, clim, gamma, cmap):
    if data.ndim == 2 or data.shape[2] == 1:
        fclim = Function(_apply_clim_float)
        fgamma = Function(_apply_gamma_float)
        fun = FunctionChain(
            None, [Function(_c2l), fclim, fgamma,
                   Function(cmap.glsl_map)])
    else:
        fclim = Function(_apply_clim)
        fgamma = Function(_apply_gamma)
        fun = FunctionChain(None,
                            [Function(_null_color_transform), fclim, fgamma])
    fclim['clim'] = clim
    fgamma['gamma'] = gamma
    return fun
コード例 #3
0
ファイル: image.py プロジェクト: harripj/napari
def _build_color_transform(grayscale: bool, clim, gamma, cmap):
    if grayscale:
        fclim = Function(_apply_clim_float)
        fgamma = Function(_apply_gamma_float)
        fun = FunctionChain(
            None, [Function(_c2l), fclim, fgamma,
                   Function(cmap.glsl_map)])
    else:
        fclim = Function(_apply_clim)
        fgamma = Function(_apply_gamma)
        fun = FunctionChain(None,
                            [Function(_null_color_transform), fclim, fgamma])
    fclim['clim'] = clim
    fgamma['gamma'] = gamma
    return fun
コード例 #4
0
def _build_color_transform(data, cmap, clim=(0., 1.)):
    if data.ndim == 2 and data.shape[1] == 1:
        fun = Function(_clim)
        fun['cmin'] = clim[0]
        fun['cmax'] = clim[1]
        fun = FunctionChain(None, [fun, Function(cmap.glsl_map)])
    else:
        fun = Function(_null_color_transform)
    return fun
コード例 #5
0
ファイル: visuals.py プロジェクト: rayg-ssec/sift
 def _build_color_transform(self):
     if self.num_channels != 3:
         raise NotImplementedError(
             "MultiChannelimageVisuals only support 3 channels.")
     else:
         # RGB/A image data (no colormap)
         fclim = Function(_apply_clim)
         fgamma = Function(_apply_gamma)
         fun = FunctionChain(
             None, [Function(_null_color_transform), fclim, fgamma])
     fclim['clim_r'] = self._texture.textures[0].clim_normalized
     fclim['clim_g'] = self._texture.textures[1].clim_normalized
     fclim['clim_b'] = self._texture.textures[2].clim_normalized
     fgamma['gamma_r'] = self.gamma[0]
     fgamma['gamma_g'] = self.gamma[1]
     fgamma['gamma_b'] = self.gamma[2]
     return fun
コード例 #6
0
ファイル: test_function.py プロジェクト: rougier/vispy
def test_FunctionChain():
    
    f1 = Function("void f1(){}")
    f2 = Function("void f2(){}")
    f3 = Function("float f3(vec3 x){}")
    f4 = Function("vec3 f4(vec3 y){}")
    f5 = Function("vec3 f5(vec4 z){}")
    
    ch = FunctionChain('chain', [f1, f2])
    assert ch.name == 'chain'
    assert ch.args == []
    assert ch.rtype == 'void'
    
    assert_in('f1', ch.compile())
    assert_in('f2', ch.compile())
    
    ch.remove(f2)
    assert_not_in('f2', ch.compile())

    ch.append(f2)
    assert_in('f2', ch.compile())

    ch = FunctionChain(funcs=[f5, f4, f3])
    assert_equal('float', ch.rtype)
    assert_equal([('vec4', 'z')], ch.args)
    assert_in('f3', ch.compile())
    assert_in('f4', ch.compile())
    assert_in('f5', ch.compile())
    assert_in(f3, ch.dependencies())
    assert_in(f4, ch.dependencies())
    assert_in(f5, ch.dependencies())
コード例 #7
0
def test_FunctionChain():

    f1 = Function("void f1(){}")
    f2 = Function("void f2(){}")
    f3 = Function("float f3(vec3 x){}")
    f4 = Function("vec3 f4(vec3 y){}")
    f5 = Function("vec3 f5(vec4 z){}")

    ch = FunctionChain('chain', [f1, f2])
    assert ch.name == 'chain'
    assert ch.args == []
    assert ch.rtype == 'void'

    assert_in('f1', ch.compile())
    assert_in('f2', ch.compile())

    ch.remove(f2)
    assert_not_in('f2', ch.compile())

    ch.append(f2)
    assert_in('f2', ch.compile())

    ch = FunctionChain(funcs=[f5, f4, f3])
    assert_equal('float', ch.rtype)
    assert_equal([('vec4', 'z')], ch.args)
    assert_in('f3', ch.compile())
    assert_in('f4', ch.compile())
    assert_in('f5', ch.compile())
    assert_in(f3, ch.dependencies())
    assert_in(f4, ch.dependencies())
    assert_in(f5, ch.dependencies())
コード例 #8
0
ファイル: image.py プロジェクト: pep8speaks/napari-gui
def _build_color_transform(data, cmap):
    if data.ndim == 2 or data.shape[2] == 1:
        fun = FunctionChain(None, [Function(_c2l), Function(cmap.glsl_map)])
    else:
        fun = Function(_null_color_transform)
    return fun