本文整理汇总了Python中numpy.empty函数的典型用法代码示例。如果您正苦于以下问题:Python empty函数的具体用法?Python empty怎么用?Python empty使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了empty函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _binopt
def _binopt(self, other, op):
"""apply the binary operation fn to two sparse matrices."""
other = self.__class__(other)
# e.g. csr_plus_csr, csr_minus_csr, etc.
fn = getattr(_sparsetools, self.format + op + self.format)
maxnnz = self.nnz + other.nnz
idx_dtype = get_index_dtype((self.indptr, self.indices,
other.indptr, other.indices),
maxval=maxnnz)
indptr = np.empty(self.indptr.shape, dtype=idx_dtype)
indices = np.empty(maxnnz, dtype=idx_dtype)
bool_ops = ['_ne_', '_lt_', '_gt_', '_le_', '_ge_']
if op in bool_ops:
data = np.empty(maxnnz, dtype=np.bool_)
else:
data = np.empty(maxnnz, dtype=upcast(self.dtype, other.dtype))
fn(self.shape[0], self.shape[1],
np.asarray(self.indptr, dtype=idx_dtype),
np.asarray(self.indices, dtype=idx_dtype),
self.data,
np.asarray(other.indptr, dtype=idx_dtype),
np.asarray(other.indices, dtype=idx_dtype),
other.data,
indptr, indices, data)
A = self.__class__((data, indices, indptr), shape=self.shape)
A.prune()
return A
开发者ID:beyondmetis,项目名称:scipy,代码行数:33,代码来源:compressed.py
示例2: __init__
def __init__(self, V, rank, win=1, circular=False, **kwargs):
"""
Parameters
----------
V : array, shape (`F`, `T`)
Matrix to analyze.
rank : int
Rank of the decomposition (i.e. number of columns of `W`
and rows of `H`).
win : int
Length of each of the convolutive bases. Defaults to 1,
i.e. the model is identical to PLCA.
circular : boolean
If True, data shifted past `T` will wrap around to
0. Defaults to False.
alphaW, alphaZ, alphaH : float or appropriately shaped array
Sparsity prior parameters for `W`, `Z`, and `H`. Negative
values lead to sparser distributions, positive values
makes the distributions more uniform. Defaults to 0 (no
prior).
**Note** that the prior is not parametrized in the
standard way where the uninformative prior has alpha=1.
"""
PLCA.__init__(self, V, rank, **kwargs)
self.win = win
self.circular = circular
self.VRW = np.empty((self.F, self.rank, self.win))
self.VRH = np.empty((self.T, self.rank))
开发者ID:EQ4,项目名称:msaf-gpl,代码行数:31,代码来源:plca.py
示例3: theta_limiter
def theta_limiter(r,cfl,theta=0.95):
r"""
Theta limiter
Additional Input:
- *theta* =
"""
a = np.empty((2,len(r)))
b = np.empty((3,len(r)))
a[0,:] = 0.001
a[1,:] = cfl
cfmod1 = np.max(a,axis=0)
a[0,:] = 0.999
cfmod2 = np.min(a,axis=0)
s1 = 2.0 / cfmod1
s2 = (1.0 + cfl) / 3.0
phimax = 2.0 / (1.0 - cfmod2)
a[0,:] = (1.0 - theta) * s1
a[1,:] = 1.0 + s2 * (r - 1.0)
left = np.max(a,axis=0)
a[0,:] = (1.0 - theta) * phimax * r
a[1,:] = theta * s1 * r
middle = np.max(a,axis=0)
b[0,:] = left
b[1,:] = middle
b[2,:] = theta*phimax
return np.min(b,axis=0)
开发者ID:tareqmalas,项目名称:pyclaw,代码行数:31,代码来源:tvd.py
示例4: test_uniform_targets
def test_uniform_targets():
enet = ElasticNetCV(fit_intercept=True, n_alphas=3)
m_enet = MultiTaskElasticNetCV(fit_intercept=True, n_alphas=3)
lasso = LassoCV(fit_intercept=True, n_alphas=3)
m_lasso = MultiTaskLassoCV(fit_intercept=True, n_alphas=3)
models_single_task = (enet, lasso)
models_multi_task = (m_enet, m_lasso)
rng = np.random.RandomState(0)
X_train = rng.random_sample(size=(10, 3))
X_test = rng.random_sample(size=(10, 3))
y1 = np.empty(10)
y2 = np.empty((10, 2))
for model in models_single_task:
for y_values in (0, 5):
y1.fill(y_values)
assert_array_equal(model.fit(X_train, y1).predict(X_test), y1)
assert_array_equal(model.alphas_, [np.finfo(float).resolution]*3)
for model in models_multi_task:
for y_values in (0, 5):
y2[:, 0].fill(y_values)
y2[:, 1].fill(2 * y_values)
assert_array_equal(model.fit(X_train, y2).predict(X_test), y2)
assert_array_equal(model.alphas_, [np.finfo(float).resolution]*3)
开发者ID:allefpablo,项目名称:scikit-learn,代码行数:29,代码来源:test_coordinate_descent.py
示例5: block2d_to_blocknd
def block2d_to_blocknd(values, items, shape, labels, ref_items=None):
""" pivot to the labels shape """
from pandas.core.internals import make_block
panel_shape = (len(items),) + shape
# TODO: lexsort depth needs to be 2!!
# Create observation selection vector using major and minor
# labels, for converting to panel format.
selector = factor_indexer(shape[1:], labels)
mask = np.zeros(np.prod(shape), dtype=bool)
mask.put(selector, True)
if mask.all():
pvalues = np.empty(panel_shape, dtype=values.dtype)
else:
dtype, fill_value = _maybe_promote(values.dtype)
pvalues = np.empty(panel_shape, dtype=dtype)
pvalues.fill(fill_value)
values = values
for i in xrange(len(items)):
pvalues[i].flat[mask] = values[:, i]
if ref_items is None:
ref_items = items
return make_block(pvalues, items, ref_items)
开发者ID:AjayRamanathan,项目名称:pandas,代码行数:28,代码来源:reshape.py
示例6: __init__
def __init__(self, ale, agent, resized_width, resized_height,
resize_method, num_epochs, epoch_length, test_length,
frame_skip, death_ends_episode, max_start_nullops):
self.ale = ale
self.agent = agent
self.num_epochs = num_epochs
self.epoch_length = epoch_length
self.test_length = test_length
self.frame_skip = frame_skip
self.death_ends_episode = death_ends_episode
self.min_action_set = ale.getMinimalActionSet()
self.resized_width = resized_width
self.resized_height = resized_height
self.resize_method = resize_method
self.width, self.height = ale.getScreenDims()
self.buffer_length = 2
self.buffer_count = 0
self.screen_rgb = np.empty((self.height, self.width, 3),
dtype=np.uint8)
self.screen_buffer = np.empty((self.buffer_length,
self.height, self.width),
dtype=np.uint8)
self.terminal_lol = False # Most recent episode ended on a loss of life
self.max_start_nullops = max_start_nullops
开发者ID:tmylk,项目名称:deep_q_rl,代码行数:26,代码来源:ale_experiment.py
示例7: _test_dtype
def _test_dtype(dtype, can_hold_na):
data = np.random.randint(0, 2, (5, 3)).astype(dtype)
indexer = [2, 1, 0, 1]
out0 = np.empty((4, 3), dtype=dtype)
out1 = np.empty((5, 4), dtype=dtype)
com.take_nd(data, indexer, out=out0, axis=0)
com.take_nd(data, indexer, out=out1, axis=1)
expected0 = data.take(indexer, axis=0)
expected1 = data.take(indexer, axis=1)
tm.assert_almost_equal(out0, expected0)
tm.assert_almost_equal(out1, expected1)
indexer = [2, 1, 0, -1]
out0 = np.empty((4, 3), dtype=dtype)
out1 = np.empty((5, 4), dtype=dtype)
if can_hold_na:
com.take_nd(data, indexer, out=out0, axis=0)
com.take_nd(data, indexer, out=out1, axis=1)
expected0 = data.take(indexer, axis=0)
expected1 = data.take(indexer, axis=1)
expected0[3, :] = np.nan
expected1[:, 3] = np.nan
tm.assert_almost_equal(out0, expected0)
tm.assert_almost_equal(out1, expected1)
else:
for i, out in enumerate([out0, out1]):
with tm.assertRaisesRegexp(TypeError, self.fill_error):
com.take_nd(data, indexer, out=out, axis=i)
# no exception o/w
data.take(indexer, out=out, axis=i)
开发者ID:5i7788,项目名称:pandas,代码行数:31,代码来源:test_common.py
示例8: __init__
def __init__(self, parent=None, width=5, height=4, dpi=60):
"""
Descript. :
"""
self.mouse_position = [0, 0]
self.max_plot_points = None
self.fig = Figure(figsize=(width, height), dpi=dpi)
self.axes = self.fig.add_subplot(111)
FigureCanvas.__init__(self, self.fig)
self.setParent(parent)
FigureCanvas.setSizePolicy(
self, QtImport.QSizePolicy.Expanding, QtImport.QSizePolicy.Expanding
)
FigureCanvas.updateGeometry(self)
self.single_curve = None
self.real_time = None
self._axis_x_array = np.empty(0)
self._axis_y_array = np.empty(0)
self._axis_x_limits = [None, None]
self._axis_y_limits = [None, None]
self._curves_dict = {}
self.setMaximumSize(2000, 2000)
开发者ID:IvarsKarpics,项目名称:mxcube,代码行数:26,代码来源:matplot_widget.py
示例9: test_empty_pass_dtype
def test_empty_pass_dtype(self):
data = 'one,two'
result = self.read_csv(StringIO(data), dtype={'one': 'u1'})
expected = DataFrame({'one': np.empty(0, dtype='u1'),
'two': np.empty(0, dtype=np.object)})
tm.assert_frame_equal(result, expected, check_index_type=False)
开发者ID:RahulHP,项目名称:pandas,代码行数:7,代码来源:c_parser_only.py
示例10: sweep_lo_dirfile
def sweep_lo_dirfile(self, Npackets_per = 10, channels = None,center_freq = 750.0e6, span = 2.0e6, bb_freqs=None,save_path = '/mnt/iqstream/lo_sweeps'):
N = Npackets_per
start = center_freq - (span/2.)
stop = center_freq + (span/2.)
step = 2.5e3
sweep_freqs = np.arange(start, stop, step)
sweep_freqs = np.round(sweep_freqs/step)*step
print 'Sweep freqs =', sweep_freqs/1.0e6
f=np.empty((len(channels),sweep_freqs.size))
i=np.empty((len(channels),sweep_freqs.size))
q=np.empty((len(channels),sweep_freqs.size))
for count,freq in enumerate(sweep_freqs):
print 'Sweep freq =', freq/1.0e6
if self.v1.set_frequency(0, freq/1.0e6, 0.01):
time.sleep(0.1)
i_buffer,q_buffer = self.get_UDP(N, freq, skip_packets=2, channels = channels)
f[:,count]=freq+bb_freqs
i[:,count]=np.mean(i_buffer,axis=0)
q[:,count]=np.mean(q_buffer,axis=0)
else:
time.sleep(0.1)
f[:,count]=freq+bb_freqs
i[:,count]=np.nan
q[:,count]=np.nan
self.v1.set_frequency(0,center_freq / (1.0e6), 0.01) # LO
return f, i, q
开发者ID:braddober,项目名称:blastfirmware,代码行数:27,代码来源:blastfirmware_dirfile.py
示例11: get_UDP
def get_UDP(self, Npackets, LO_freq, skip_packets=2, channels = None):
#Npackets = np.int(time_interval * self.accum_freq)
I_buffer = np.empty((Npackets + skip_packets, len(channels)))
Q_buffer = np.empty((Npackets + skip_packets, len(channels)))
self.fpga.write_int('pps_start', 1)
count = 0
while count < Npackets + skip_packets:
packet = self.s.recv(8192)
data = np.fromstring(packet,dtype = '<i').astype('float')
data /= 2.0**17
data /= (self.accum_len/512.)
ts = (np.fromstring(packet[-4:],dtype = '<i').astype('float')/ self.fpga_samp_freq)*1.0e3 # ts in ms
odd_chan = channels[1::2]
even_chan = channels[0::2]
I_odd = data[1024 + ((odd_chan - 1) / 2)]
Q_odd = data[1536 + ((odd_chan - 1) /2)]
I_even = data[0 + (even_chan/2)]
Q_even = data[512 + (even_chan/2)]
even_phase = np.arctan2(Q_even,I_even)
odd_phase = np.arctan2(Q_odd,I_odd)
if len(channels) % 2 > 0:
I = np.hstack(zip(I_even[:len(I_odd)], I_odd))
Q = np.hstack(zip(Q_even[:len(Q_odd)], Q_odd))
I = np.hstack((I, I_even[-1]))
Q = np.hstack((Q, Q_even[-1]))
I_buffer[count] = I
Q_buffer[count] = Q
else:
I = np.hstack(zip(I_even, I_odd))
Q = np.hstack(zip(Q_even, Q_odd))
I_buffer[count] = I
Q_buffer[count] = Q
count += 1
return I_buffer[skip_packets:],Q_buffer[skip_packets:]
开发者ID:braddober,项目名称:blastfirmware,代码行数:35,代码来源:blastfirmware_dirfile.py
示例12: get_stream
def get_stream(self, chan, time_interval):
self.fpga.write_int('pps_start', 1)
#self.phases = np.empty((len(self.freqs),Npackets))
Npackets = np.int(time_interval * self.accum_freq)
Is = np.empty(Npackets)
Qs = np.empty(Npackets)
phases = np.empty(Npackets)
count = 0
while count < Npackets:
packet = self.s.recv(8192 + 42) # total number of bytes including 42 byte header
header = np.fromstring(packet[:42],dtype = '<B')
roach_mac = header[6:12]
filter_on = np.array([2, 68, 1, 2, 13, 33])
if np.array_equal(roach_mac,filter_on):
data = np.fromstring(packet[42:],dtype = '<i').astype('float')
data /= 2.0**17
data /= (self.accum_len/512.)
ts = (np.fromstring(packet[-4:],dtype = '<i').astype('float')/ self.fpga_samp_freq)*1.0e3 # ts in ms
# To stream one channel, make chan an argument
if (chan % 2) > 0:
I = data[1024 + ((chan - 1) / 2)]
Q = data[1536 + ((chan - 1) /2)]
else:
I = data[0 + (chan/2)]
Q = data[512 + (chan/2)]
phase = np.arctan2([Q],[I])
Is[count]=I
Qs[count]=Q
phases[count]=phase
else:
continue
count += 1
return Is, Qs, phases
开发者ID:braddober,项目名称:blastfirmware,代码行数:33,代码来源:blastfirmware_dirfile.py
示例13: _TO_DELETE_initialize_drifters
def _TO_DELETE_initialize_drifters(self, driftersPerOceanModel):
"""
Initialize drifters and attach them for each particle.
"""
self.driftersPerOceanModel = np.int32(driftersPerOceanModel)
# Define mid-points for the different drifters
# Decompose the domain, so that we spread the drifters as much as possible
sub_domains_y = np.int(np.round(np.sqrt(self.driftersPerOceanModel)))
sub_domains_x = np.int(np.ceil(1.0*self.driftersPerOceanModel/sub_domains_y))
self.midPoints = np.empty((driftersPerOceanModel, 2))
for sub_y in range(sub_domains_y):
for sub_x in range(sub_domains_x):
drifter_id = sub_y*sub_domains_x + sub_x
if drifter_id >= self.driftersPerOceanModel:
break
self.midPoints[drifter_id, 0] = (sub_x + 0.5)*self.nx*self.dx/sub_domains_x
self.midPoints[drifter_id, 1] = (sub_y + 0.5)*self.ny*self.dy/sub_domains_y
# Loop over particles, sample drifters, and attach them
for i in range(self.numParticles+1):
drifters = GPUDrifterCollection.GPUDrifterCollection(self.gpu_ctx, self.driftersPerOceanModel,
observation_variance=self.observation_variance,
boundaryConditions=self.boundaryConditions,
domain_size_x=self.nx*self.dx, domain_size_y=self.ny*self.dy)
initPos = np.empty((self.driftersPerOceanModel, 2))
for d in range(self.driftersPerOceanModel):
initPos[d,:] = np.random.multivariate_normal(self.midPoints[d,:], self.initialization_cov_drifters)
drifters.setDrifterPositions(initPos)
self.particles[i].attachDrifters(drifters)
开发者ID:setmar,项目名称:gpu-ocean,代码行数:31,代码来源:OceanNoiseEnsemble.py
示例14: test_buffer_mode
def test_buffer_mode(self) :
# allocate something manifestly too short, should raise a value error
buff = np.empty(0, dtype=np.int64)
self.assertRaises(ValueError,
query_disc,
self.NSIDE, self.vec, self.radius, inclusive=True, buff=buff)
# allocate something of wrong type, should raise a value error
buff = np.empty(nside2npix(self.NSIDE), dtype=np.float64)
self.assertRaises(ValueError,
query_disc,
self.NSIDE, self.vec, self.radius, inclusive=True, buff=buff)
# allocate something acceptable, should succeed and return a subview
buff = np.empty(nside2npix(self.NSIDE), dtype=np.int64)
result = query_disc(self.NSIDE, self.vec, self.radius, inclusive=True, buff=buff)
assert result.base is buff
np.testing.assert_array_equal(
result,
np.array([ 0, 3, 4, 5, 11, 12, 13, 23 ])
)
开发者ID:Goutte,项目名称:healpy,代码行数:26,代码来源:test_query_disc.py
示例15: get_rpn_batch
def get_rpn_batch(roidb):
"""
prototype for rpn batch: data, im_info, gt_boxes
:param roidb: ['image', 'flipped'] + ['gt_boxes', 'boxes', 'gt_classes']
:return: data, label
"""
assert len(roidb) == 1, 'Single batch only'
imgs, roidb = get_image(roidb)
im_array = imgs[0]
im_info = np.array([roidb[0]['im_info']], dtype=np.float32)
# gt boxes: (x1, y1, x2, y2, cls)
if roidb[0]['gt_classes'].size > 0:
gt_inds = np.where(roidb[0]['gt_classes'] != 0)[0]
gt_boxes = np.empty((roidb[0]['boxes'].shape[0], 5), dtype=np.float32)
gt_boxes[:, 0:4] = roidb[0]['boxes'][gt_inds, :]
gt_boxes[:, 4] = roidb[0]['gt_classes'][gt_inds]
else:
gt_boxes = np.empty((0, 5), dtype=np.float32)
data = {'data': im_array,
'im_info': im_info}
label = {'gt_boxes': gt_boxes}
return data, label
开发者ID:CoderHHX,项目名称:incubator-mxnet,代码行数:25,代码来源:rpn.py
示例16: test_empty_with_mangled_column_pass_dtype_by_indexes
def test_empty_with_mangled_column_pass_dtype_by_indexes(self):
data = 'one,one'
result = self.read_csv(StringIO(data), dtype={0: 'u1', 1: 'f'})
expected = DataFrame(
{'one': np.empty(0, dtype='u1'), 'one.1': np.empty(0, dtype='f')})
tm.assert_frame_equal(result, expected, check_index_type=False)
开发者ID:RahulHP,项目名称:pandas,代码行数:7,代码来源:c_parser_only.py
示例17: setconstants
def setconstants(self, samplefac, colors):
self.NCYCLES = 100 # Number of learning cycles
self.NETSIZE = colors # Number of colours used
self.SPECIALS = 3 # Number of reserved colours used
self.BGCOLOR = self.SPECIALS-1 # Reserved background colour
self.CUTNETSIZE = self.NETSIZE - self.SPECIALS
self.MAXNETPOS = self.NETSIZE - 1
self.INITRAD = self.NETSIZE/8 # For 256 colours, radius starts at 32
self.RADIUSBIASSHIFT = 6
self.RADIUSBIAS = 1 << self.RADIUSBIASSHIFT
self.INITBIASRADIUS = self.INITRAD * self.RADIUSBIAS
self.RADIUSDEC = 30 # Factor of 1/30 each cycle
self.ALPHABIASSHIFT = 10 # Alpha starts at 1
self.INITALPHA = 1 << self.ALPHABIASSHIFT # biased by 10 bits
self.GAMMA = 1024.0
self.BETA = 1.0/1024.0
self.BETAGAMMA = self.BETA * self.GAMMA
self.network = np.empty((self.NETSIZE, 3), dtype='float64') # The network itself
self.colormap = np.empty((self.NETSIZE, 4), dtype='int32') # The network itself
self.netindex = np.empty(256, dtype='int32') # For network lookup - really 256
self.bias = np.empty(self.NETSIZE, dtype='float64') # Bias and freq arrays for learning
self.freq = np.empty(self.NETSIZE, dtype='float64')
self.pixels = None
self.samplefac = samplefac
self.a_s = {}
开发者ID:FrankNaets,项目名称:pyNastran,代码行数:33,代码来源:images2gif.py
示例18: cart2sph
def cart2sph(z, y, x):
"""Convert from cartesian coordinates (x,y,z) to spherical (elevation,
azimuth, radius). Output is in degrees.
usage:
array3xN[el,az,rad] = cart2sph(array3xN[x,y,z])
OR
elevation, azimuth, radius = cart2sph(x,y,z)
If working in DKL space, z = Luminance, y = S and x = LM"""
width = len(z)
elevation = numpy.empty([width,width])
radius = numpy.empty([width,width])
azimuth = numpy.empty([width,width])
radius = numpy.sqrt(x**2 + y**2 + z**2)
azimuth = numpy.arctan2(y, x)
#Calculating the elevation from x,y up
elevation = numpy.arctan2(z, numpy.sqrt(x**2+y**2))
#convert azimuth and elevation angles into degrees
azimuth *=(180.0/numpy.pi)
elevation *=(180.0/numpy.pi)
sphere = numpy.array([elevation, azimuth, radius])
sphere = numpy.rollaxis(sphere, 0, 3)
return sphere
开发者ID:glupyan,项目名称:psychopy,代码行数:29,代码来源:misc.py
示例19: interpolate
def interpolate(self, points, diff=False):
"""Interpolate splines at manu points."""
import time
if points.ndim == 1:
raise Exception('Expected 2d array. Received {}d array'.format(points.ndim))
if points.shape[1] != self.d:
raise Exception('Second dimension should be {}. Received : {}.'.format(self.d, points.shape[0]))
if not np.all( np.isfinite(points)):
raise Exception('Spline interpolator evaluated at non-finite points.')
n_sp = self.__mcoeffs__.shape[-1]
N = points.shape[0]
d = points.shape[1]
if not diff:
from .eval_cubic import vec_eval_cubic_splines
values = np.empty((N,n_sp), dtype=float)
vec_eval_cubic_splines(self.a, self.b, self.orders, self.__mcoeffs__, points, values)
return values
else:
from .eval_cubic import vec_eval_cubic_splines_G
values = np.empty((N,n_sp), dtype=float)
dvalues = np.empty((N,d,n_sp), dtype=float)
vec_eval_cubic_splines_G(self.a, self.b, self.orders, self.__mcoeffs__, points, values, dvalues)
return [values, dvalues]
开发者ID:Cyberface,项目名称:interpolation.py,代码行数:28,代码来源:splines.py
示例20: convert_yuv420_to_rgb_image
def convert_yuv420_to_rgb_image(y_plane, u_plane, v_plane,
w, h,
ccm_yuv_to_rgb=DEFAULT_YUV_TO_RGB_CCM,
yuv_off=DEFAULT_YUV_OFFSETS):
"""Convert a YUV420 8-bit planar image to an RGB image.
Args:
y_plane: The packed 8-bit Y plane.
u_plane: The packed 8-bit U plane.
v_plane: The packed 8-bit V plane.
w: The width of the image.
h: The height of the image.
ccm_yuv_to_rgb: (Optional) the 3x3 CCM to convert from YUV to RGB.
yuv_off: (Optional) offsets to subtract from each of Y,U,V values.
Returns:
RGB float-3 image array, with pixel values in [0.0, 1.0].
"""
y = numpy.subtract(y_plane, yuv_off[0])
u = numpy.subtract(u_plane, yuv_off[1]).view(numpy.int8)
v = numpy.subtract(v_plane, yuv_off[2]).view(numpy.int8)
u = u.reshape(h/2, w/2).repeat(2, axis=1).repeat(2, axis=0)
v = v.reshape(h/2, w/2).repeat(2, axis=1).repeat(2, axis=0)
yuv = numpy.dstack([y, u.reshape(w*h), v.reshape(w*h)])
flt = numpy.empty([h, w, 3], dtype=numpy.float32)
flt.reshape(w*h*3)[:] = yuv.reshape(h*w*3)[:]
flt = numpy.dot(flt.reshape(w*h,3), ccm_yuv_to_rgb.T).clip(0, 255)
rgb = numpy.empty([h, w, 3], dtype=numpy.uint8)
rgb.reshape(w*h*3)[:] = flt.reshape(w*h*3)[:]
return rgb.astype(numpy.float32) / 255.0
开发者ID:xin3liang,项目名称:platform_pdk,代码行数:30,代码来源:image.py
注:本文中的numpy.empty函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论