コード例 #1
0
ファイル: int2bits.py プロジェクト: AndreaCensi/boot_olympics
    def transform_streamels(self, streamels):
        check_streamels_2D(streamels)
        shape = streamels.shape
        # TODO: use normal function
        if not streamels_all_of_kind(streamels, ValueFormats.Discrete):
            msg = 'Bits2int only supports discrete streams.'
            raise UnsupportedSpec(msg)

        if (np.any(streamels['lower'] != 0) or
             np.any(streamels['upper'] != 1)):
            msg = 'I expect only bits as input.'
            raise UnsupportedSpec(msg)

        nvalues, nbits = shape

        max_value = int(2 ** nbits - 1)
        self.codewords = self.codefunc(max_value)
        self.codewords_inv = {}
        for i, x in enumerate(self.codewords):
            self.codewords_inv[x] = i
        # print('codewords: %s' % self.codewords)

        streamels2 = np.zeros(nvalues, streamel_dtype)
        streamels2['kind'] = ValueFormats.Discrete
        streamels2['lower'] = 0
        streamels2['upper'] = 2 ** nbits - 1
        streamels2['default'] = self.transform_value(streamels['default'])
        return streamels2
コード例 #2
0
ファイル: cam1d.py プロジェクト: AndreaCensi/yc1304
 def transform_streamels(self, streamels):
     check_streamels_2D(streamels)
     check_streamels_range(streamels, 0, 1)
     
     _, W = streamels.shape  
     streamels2 = make_streamels_1D_float(nstreamels=W, lower=0, upper=1)
     return streamels2
コード例 #3
0
ファイル: resample.py プロジェクト: AndreaCensi/boot_olympics
 def transform_streamels(self, streamels):
     # Check that it is a 2D float image
     check_streamels_2D(streamels)
     check_streamels_continuous(streamels)
     self.shape_from = streamels.shape
     self.vmin = np.min(streamels['lower'])
     self.vmax = np.max(streamels['upper'])
     return make_streamels_2D_float(self.shape_to,
                                    lower=self.vmin, upper=self.vmax)
コード例 #4
0
    def transform_streamels(self, streamels):
        check_streamels_2D(streamels)
        check_streamels_continuous(streamels)
        check_streamels_range(streamels, 0, 1)

        N, _ = streamels.shape
        shape2 = N,
        streamels2 = np.empty(shape=shape2, dtype=streamel_dtype)
        streamels2['kind'].flat[:] = ValueFormats.Continuous
        streamels2['lower'].flat[:] = 0
        streamels2['upper'].flat[:] = 1
        streamels2['default'] = self.transform_value(streamels['default'])
        return streamels2