python numpy diff_Python numpy.uint16方法代码示例

本文详细介绍了Python numpy.uint16方法的使用,通过29个精选代码示例,涵盖不同应用场景,包括图像处理、数据转换、数组操作等,帮助读者深入理解该方法的功能和应用。
摘要由CSDN通过智能技术生成

本文整理汇总了Python中numpy.uint16方法的典型用法代码示例。如果您正苦于以下问题:Python numpy.uint16方法的具体用法?Python numpy.uint16怎么用?Python numpy.uint16使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块numpy的用法示例。

在下文中一共展示了numpy.uint16方法的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: execute

​点赞 7

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import uint16 [as 别名]

def execute(self):

img_h = self.img.shape[0]

img_w = self.img.shape[1]

img_c = self.img.shape[2]

gc_img = np.empty((img_h, img_w, img_c), np.uint16)

for y in range(self.img.shape[0]):

for x in range(self.img.shape[1]):

if self.mode == 'rgb':

gc_img[y, x, 0] = self.lut[self.img[y, x, 0]]

gc_img[y, x, 1] = self.lut[self.img[y, x, 1]]

gc_img[y, x, 2] = self.lut[self.img[y, x, 2]]

gc_img[y, x, :] = gc_img[y, x, :] / 4

elif self.mode == 'yuv':

gc_img[y, x, 0] = self.lut[0][self.img[y, x, 0]]

gc_img[y, x, 1] = self.lut[1][self.img[y, x, 1]]

gc_img[y, x, 2] = self.lut[1][self.img[y, x, 2]]

self.img = gc_img

return self.img

开发者ID:cruxopen,项目名称:openISP,代码行数:20,

示例2: execute

​点赞 6

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import uint16 [as 别名]

def execute(self):

img_pad = self.padding()

img_pad = img_pad.astype(np.uint16)

raw_h = self.img.shape[0]

raw_w = self.img.shape[1]

nlm_img = np.empty((raw_h, raw_w), np.uint16)

kernel = np.ones((2*self.ds+1, 2*self.ds+1)) / pow(2*self.ds+1, 2)

for y in range(img_pad.shape[0] - 2 * self.Ds):

for x in range(img_pad.shape[1] - 2 * self.Ds):

center_y = y + self.Ds

center_x = x + self.Ds

sweight, average, wmax = self.calWeights(img_pad, kernel, center_y, center_x)

average = average + wmax * img_pad[center_y, center_x]

sweight = sweight + wmax

nlm_img[y,x] = average / sweight

self.img = nlm_img

return self.clipping()

开发者ID:cruxopen,项目名称:openISP,代码行数:19,

示例3: execute

​点赞 6

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import uint16 [as 别名]

def execute(self):

img_pad = self.padding()

raw_h = self.img.shape[0]

raw_w = self.img.shape[1]

aaf_img = np.empty((raw_h, raw_w), np.uint16)

for y in range(img_pad.shape[0] - 4):

for x in range(img_pad.shape[1] - 4):

p0 = img_pad[y + 2, x + 2]

p1 = img_pad[y, x]

p2 = img_pad[y, x + 2]

p3 = img_pad[y, x + 4]

p4 = img_pad[y + 2, x]

p5 = img_pad[y + 2, x + 4]

p6 = img_pad[y + 4, x]

p7 = img_pad[y + 4, x + 2]

p8 = img_pad[y + 4, x + 4]

aaf_img[y, x] = (p0 * 8 + p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8) / 16

self.img = aaf_img

return self.img

开发者ID:cruxopen,项目名称:openISP,代码行数:21,

示例4: test_subheader

​点赞 6

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import uint16 [as 别名]

def test_subheader(self):

assert_equal(self.subhdr.get_shape() , (10,10,3))

assert_equal(self.subhdr.get_nframes() , 1)

assert_equal(self.subhdr.get_nframes(),

len(self.subhdr.subheaders))

assert_equal(self.subhdr._check_affines(), True)

assert_array_almost_equal(np.diag(self.subhdr.get_frame_affine()),

np.array([ 2.20241979, 2.20241979, 3.125, 1.]))

assert_equal(self.subhdr.get_zooms()[0], 2.20241978764534)

assert_equal(self.subhdr.get_zooms()[2], 3.125)

assert_equal(self.subhdr._get_data_dtype(0),np.uint16)

#assert_equal(self.subhdr._get_frame_offset(), 1024)

assert_equal(self.subhdr._get_frame_offset(), 1536)

dat = self.subhdr.raw_data_from_fileobj()

assert_equal(dat.shape, self.subhdr.get_shape())

scale_factor = self.subhdr.subheaders[0]['scale_factor']

assert_equal(self.subhdr.subheaders[0]['scale_factor'].item(),1.0)

ecat_calib_factor = self.hdr['ecat_calibration_factor']

assert_equal(ecat_calib_factor, 25007614.0)

开发者ID:ME-ICA,项目名称:me-ica,代码行数:21,

示例5: test_able_int_type

​点赞 6

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import uint16 [as 别名]

def test_able_int_type():

# The integer type cabable of containing values

for vals, exp_out in (

([0, 1], np.uint8),

([0, 255], np.uint8),

([-1, 1], np.int8),

([0, 256], np.uint16),

([-1, 128], np.int16),

([0.1, 1], None),

([0, 2**16], np.uint32),

([-1, 2**15], np.int32),

([0, 2**32], np.uint64),

([-1, 2**31], np.int64),

([-1, 2**64-1], None),

([0, 2**64-1], np.uint64),

([0, 2**64], None)):

assert_equal(able_int_type(vals), exp_out)

开发者ID:ME-ICA,项目名称:me-ica,代码行数:19,

示例6: test_can_cast

​点赞 6

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import uint16 [as 别名]

def test_can_cast():

tests = ((np.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值