本文整理汇总了Python中skimage.util.random_noise方法的典型用法代码示例。如果您正苦于以下问题:Python util.random_noise方法的具体用法?Python util.random_noise怎么用?Python util.random_noise使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类skimage.util
的用法示例。
在下文中一共展示了util.random_noise方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: new_crap_AG_SP
# 需要导入模块: from skimage import util [as 别名]
# 或者: from skimage.util import random_noise [as 别名]
def new_crap_AG_SP(x, scale=4, upsample=False):
xn = np.array(x)
xorig_max = xn.max()
xn = xn.astype(np.float32)
xn /= float(np.iinfo(np.uint8).max)
lvar = filters.gaussian(xn, sigma=5) + 1e-10
xn = random_noise(xn, mode='localvar', local_vars=lvar*0.5)
xn = random_noise(xn, mode='salt', amount=0.005)
xn = random_noise(xn, mode='pepper', amount=0.005)
new_max = xn.max()
x = xn
if new_max > 0:
xn /= new_max
xn *= xorig_max
multichannel = len(x.shape) > 2
xn = rescale(xn, scale=1/scale, order=1, multichannel=multichannel)
return PIL.Image.fromarray(xn.astype(np.uint8))
示例2: _prepare_images
# 需要导入模块: from skimage import util [as 别名]
# 或者: from skimage.util import random_noise [as 别名]
def _prepare_images(path_out, im_size=IMAGE_SIZE):
""" generate and prepare synth. images for registration
:param str path_out: path to the folder
:param tuple(int,int) im_size: desired image size
:return tuple(str,str): paths to target and source image
"""
image = resize(data.astronaut(), output_shape=im_size, mode='constant')
img_target = random_noise(image, var=IMAGE_NOISE)
path_img_target = os.path.join(path_out, NAME_IMAGE_TARGET)
io.imsave(path_img_target, img_target)
# warp synthetic image
tform = AffineTransform(scale=(0.9, 0.9),
rotation=0.2,
translation=(200, -50))
img_source = warp(image, tform.inverse, output_shape=im_size)
img_source = random_noise(img_source, var=IMAGE_NOISE)
path_img_source = os.path.join(path_out, NAME_IMAGE_SOURCE)
io.imsave(path_img_source, img_source)
return path_img_target, path_img_source
示例3: new_crap
# 需要导入模块: from skimage import util [as 别名]
# 或者: from skimage.util import random_noise [as 别名]
def new_crap(x, scale=4, upsample=False):
xn = np.array(x)
xorig_max = xn.max()
xn = xn.astype(np.float32)
xn /= float(np.iinfo(np.uint8).max)
xn = random_noise(xn, mode='salt', amount=0.005)
xn = random_noise(xn, mode='pepper', amount=0.005)
lvar = filters.gaussian(xn, sigma=5) + 1e-10
xn = random_noise(xn, mode='localvar', local_vars=lvar*0.5)
new_max = xn.max()
x = xn
if new_max > 0:
xn /= new_max
xn *= xorig_max
multichannel = len(x.shape) > 2
x = rescale(x, scale=1/scale, order=1, multichannel=multichannel)
return PIL.Image.fromarray(x.astype(np.uint8))
示例4: fluo_AG_D
# 需要导入模块: from skimage import util [as 别名]
# 或者: from skimage.util import random_noise [as 别名]
def fluo_AG_D(x, scale=4, upsample=False):
xn = np.array(x)
xorig_max = xn.max()
xn = xn.astype(np.float32)
xn /= float(np.iinfo(np.uint8).max)
lvar = filters.gaussian(xn, sigma=5) + 1e-10
xn = random_noise(xn, mode='localvar', local_vars=lvar*0.5)
new_max = xn.max()
x = xn
if new_max > 0:
xn /= new_max
xn *= xorig_max
x_down = npzoom(x, 1/scale, order=1)
#x_up = npzoom(x_down, scale, order=1)
return PIL.Image.fromarray(x_down.astype(np.uint8))
示例5: fluo_SP_AG_D_sameas_preprint
# 需要导入模块: from skimage import util [as 别名]
# 或者: from skimage.util import random_noise [as 别名]
def fluo_SP_AG_D_sameas_preprint(x, scale=4, upsample=False):
xn = np.array(x)
xorig_max = xn.max()
xn = xn.astype(np.float32)
xn /= float(np.iinfo(np.uint8).max)
xn = random_noise(xn, mode='salt', amount=0.005)
xn = random_noise(xn, mode='pepper', amount=0.005)
lvar = filters.gaussian(xn, sigma=5) + 1e-10
xn = random_noise(xn, mode='localvar', local_vars=lvar*0.5)
new_max = xn.max()
x = xn
if new_max > 0:
xn /= new_max
xn *= xorig_max
x_down = npzoom(x, 1/scale, order=1)
return PIL.Image.fromarray(x_down.astype(np.uint8))
示例6: _my_noise
# 需要导入模块: from skimage import util [as 别名]
# 或者: from skimage.util import random_noise [as 别名]
def _my_noise(x, gauss_sigma:uniform=0.01, pscale:uniform=10):
xn = x.numpy()
xorig_max = xn.max()
xn = random_noise(xn, mode='salt', amount=0.005)
xn = random_noise(xn, mode='pepper', amount=0.005)
lvar = filters.gaussian(x, sigma=5) + 1e-10
xn = random_noise(xn, mode='localvar', local_vars=lvar*0.5)
#xn = np.random.poisson(xn*pscale)/pscale
#xn += np.random.normal(0, gauss_sigma*xn.std(), size=x.shape)
x = x.new(xn)
new_max = xn.max()
if new_max > 0:
xn /= new_max
xn *= xorig_max
return x
示例7: speckle_crap
# 需要导入模块: from skimage import util [as 别名]
# 或者: from skimage.util import random_noise [as 别名]
def speckle_crap(img):
img = random_noise(img, mode='speckle', var=0.02, clip=True)
return img
示例8: fluo_SP_D
# 需要导入模块: from skimage import util [as 别名]
# 或者: from skimage.util import random_noise [as 别名]
def fluo_SP_D(x, scale=4, upsample=False):
xn = np.array(x)
xorig_max = xn.max()
xn = xn.astype(np.float32)
xn /= float(np.iinfo(np.uint8).max)
xn = random_noise(xn, mode='salt', amount=0.005)
xn = random_noise(xn, mode='pepper', amount=0.005)
new_max = xn.max()
x = xn
if new_max > 0:
xn /= new_max
xn *= xorig_max
x_down = npzoom(x, 1/scale, order=1)
#x_up = npzoom(x_down, scale, order=1)
return PIL.Image.fromarray(x_down.astype(np.uint8))
示例9: em_AG_D_sameas_preprint
# 需要导入模块: from skimage import util [as 别名]
# 或者: from skimage.util import random_noise [as 别名]
def em_AG_D_sameas_preprint(x, scale=4, upsample=False):
lvar = filters.gaussian(x, sigma=3)
x = random_noise(x, mode='localvar', local_vars=lvar*0.05)
x_down = npzoom(x, 1/scale, order=1)
x_up = npzoom(x_down, scale, order=1)
return x_down, x_up
示例10: em_P_D_001
# 需要导入模块: from skimage import util [as 别名]
# 或者: from skimage.util import random_noise [as 别名]
def em_P_D_001(x, scale=4, upsample=False):
x = random_noise(x, mode='poisson', seed=1)
x_down = npzoom(x, 1/scale, order=1)
x_up = npzoom(x_down, scale, order=1)
return x_down, x_up
###not sure about this one
示例11: em_AG_P_D_001
# 需要导入模块: from skimage import util [as 别名]
# 或者: from skimage.util import random_noise [as 别名]
def em_AG_P_D_001(x, scale=4, upsample=False):
poisson_noisemap = np.random.poisson(x, size=None)
set_trace()
lvar = filters.gaussian(x, sigma=3)
x = random_noise(x, mode='localvar', local_vars=lvar*0.05)
x = x + poisson_noisemap
#x = x - x.min()
#x = x/x.max()
x_down = npzoom(x, 1/scale, order=1)
x_up = npzoom(x_down, scale, order=1)
return x_down, x_up
示例12: classic_crap
# 需要导入模块: from skimage import util [as 别名]
# 或者: from skimage.util import random_noise [as 别名]
def classic_crap(img):
img = random_noise(img, mode='salt', amount=0.005)
img = random_noise(img, mode='pepper', amount=0.005)
lvar = filters.gaussian(img, sigma=5) + 1e-6
img = random_noise(img, mode='localvar', local_vars=lvar * 0.5)
return img
示例13: apply_random_noise
# 需要导入模块: from skimage import util [as 别名]
# 或者: from skimage.util import random_noise [as 别名]
def apply_random_noise(self, image, percent=30):
"""Apply random noise on an image (not used)"""
random = np.random.randint(0, 100)
if random < percent:
image = random_noise(image)
return image
示例14: execute
# 需要导入模块: from skimage import util [as 别名]
# 或者: from skimage.util import random_noise [as 别名]
def execute(self, image_array: ndarray):
return random_noise(image_array)
示例15: random_noise
# 需要导入模块: from skimage import util [as 别名]
# 或者: from skimage.util import random_noise [as 别名]
def random_noise(self, probability: float):
self.__add_operation(RandomNoise(probability))