本文整理汇总了Python中wand.image.Image.gaussian_blur方法的典型用法代码示例。如果您正苦于以下问题:Python Image.gaussian_blur方法的具体用法?Python Image.gaussian_blur怎么用?Python Image.gaussian_blur使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wand.image.Image
的用法示例。
在下文中一共展示了Image.gaussian_blur方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: slice02
# 需要导入模块: from wand.image import Image [as 别名]
# 或者: from wand.image.Image import gaussian_blur [as 别名]
def slice02():
# Resize image to height (but do not change the aspect ratio)
#
req_width = 595
req_height = 486
baby_img = Image(filename=IMAGE_PATH + "baby_cc_sh.png")
baby_img = resize_to_height(baby_img, req_height)
# For this particular image, reflect image along vertical
# axis to have face directed towards right of page.
#
baby_img.flop()
# Create the the gradient transition that will later be used
# in the opacity mask.
#
gradient_blob = create_gradient_blob(req_height, 75, gradient([
(1.0, (0x00, 0x00, 0x00), (0xFF, 0xFF, 0xFF)), # top
]))
gradient_img = Image(blob=gradient_blob)
gradient_img.rotate(90.0)
# When building the opacity mask, must start with an image
# having a solid colour (i.e., begin as a "matte" image).
# Without this, the later "composite_channel" operations
# will simply not work.
#
opacity_mask = new_blank_png(req_width, req_height, color=Color('white'))
left_field = new_blank_png(230, req_height, Color('white'))
right_field = new_blank_png(290, req_height, Color('black'))
opacity_mask.composite(left_field, 0, 0)
opacity_mask.composite(right_field, 230+75, 0)
opacity_mask.composite(gradient_img, 230, 0)
# Now take the resized baby image and have it fade to the right
# (in order to blend with later operations).
#
face_img = new_blank_png(req_width, req_height)
face_img.composite(baby_img, 0, 0)
face_img.composite_channel(channel='all_channels', image=opacity_mask,
operator='copy_opacity')
# Bring in the illustrative image that will eventually be blended in
# with the child's face.
#
accent_img = Image(filename = IMAGE_PATH + "funky_illustration.png")
accent_img = resize_to_percent(accent_img, 60)
accent_img = resize_to_height(accent_img, 486)
cropped_img = accent_img.clone()
cropped_img.crop(top=0, left=275, width=340, height=486)
screen_img = new_blank_png(340, 486, color=Color('rgb(150,150,150)'))
cropped_img.composite_channel(channel='all_channels', image=screen_img,
operator='screen')
accent_img = new_blank_png(req_width, req_height)
accent_img.composite_channel(channel='all_channels', image=cropped_img,
operator='over', left=255, top=0)
accent_img.gaussian_blur(3.0, 1.0)
opacity_mask = new_blank_png(req_width, req_height, color=Color('white'))
left_field = new_blank_png(260, req_height, Color('black'))
right_field = new_blank_png(290, req_height, Color('white'))
opacity_mask.composite(left_field, 0, 0)
opacity_mask.composite(right_field, 260+75, 0)
gradient_img.rotate(180)
opacity_mask.composite(gradient_img, 260, 0)
accent_img.composite_channel(channel='all_channels', image=opacity_mask,
operator='copy_opacity')
# Now layer the accent image with the child's face
#
accent_img.composite_channel(channel='all_channels', image=face_img,
operator='over')
full_slice = accent_img
# Finally, add the text field on the right of the image.
#
text_field = new_blank_png(212, req_height, color=Color('rgb(190,30,45)'))
text_field_mask = new_blank_png(212, req_height, color=Color('rgb(220,220,220)'))
text_field.composite_channel(channel='all_channels', image=text_field_mask,
operator='copy_opacity')
full_slice.composite(text_field, 384, 0)
draw = Drawing()
draw.font = FONT_BOLD
draw.font_size = 24
draw.fill_color = Color('white')
draw.text(395, 175, "Liam Mulcahy")
draw.font = FONT_REGULAR
draw.font_size = 20
draw.text(395, 200, "Eyes to the Future")
draw.font = FONT_ITALIC
draw.font_size = 20
draw.text(395, 250, 'How dreams of')
draw.text(395, 275, 'future enterprise')
draw.text(395, 300, 'success are')
draw.text(395, 325, 'starting while still')
draw.text(395, 350, 'in nappies!')
draw(full_slice)
#.........这里部分代码省略.........
示例2: print
# 需要导入模块: from wand.image import Image [as 别名]
# 或者: from wand.image.Image import gaussian_blur [as 别名]
# print(randomScene)
randomSceneImage = Image(filename=randomScene)
widthRange = randomSceneImage.size[0] - 100
heightRange = randomSceneImage.size[1] - 32
randomSceneImage.crop(left=random.randint(0, widthRange), top=random.randint(0, heightRange), width=100, height=32)
# randomSceneImage.save(filename='.\\photoWand\\'+str(j+1) + '_texture.jpg')
# --------------------------------------------------------------
# ----------create the base layer, base texture +base color-----
baseImage = Image(width=100, height=32, background=Color('rgb('+str(color1[0])+','+str(color1[1])+','+str(color1[2])+')'))
# print('base_color = ' + 'rgb('+str(color1[0])+','+str(color1[1])+','+str(color1[2])+')')
baseImage.composite_channel(channel='undefined', image=randomSceneImage, operator='blend', left=0, top=0)
baseImage.gaussian_blur(4, 10)
baseImage.resolution = (96, 96)
# --------------------------------------------------------------
# -----generate font--------------------------------------------
word = python2access.randomWords()
fonts = pathwalk('.\\googleFonts\\')
randomFont = random.choice(fonts)
randomFont = randomFont[0] + randomFont[1]
initialPointsize = 45
draw = Drawing()
draw.font = randomFont
tmp = int(math.floor(abs(random.gauss(0, 1))*6))
示例3: generate
# 需要导入模块: from wand.image import Image [as 别名]
# 或者: from wand.image.Image import gaussian_blur [as 别名]
def generate(count):
# ---------------get three colors-------------------------------
colorString = random.choice(result)
color = []
for i in colorString:
color += [int(i)]
# for i in range(len(color)):
# color[i] = math.floor(color[i]/255*65535)
color1 = color[0:3]
color2 = color[3:6]
color3 = color[6:9]
# --------------------------------------------------------------
# ----------get the base layer texture--------------------------
Scenes = pathwalk('./SceneData')
randomScene = random.choice(Scenes)
randomScene = randomScene[0] + '/' + randomScene[1]
print(randomScene)
randomSceneImage = Image(filename=randomScene)
widthRange = randomSceneImage.size[0] - 100
heightRange = randomSceneImage.size[1] - 32
randomSceneImage.crop(left=random.randint(0, widthRange), top=random.randint(0, heightRange), width=100, height=32)
# randomSceneImage.save(filename='.\\photoWand\\'+str(j+1) + '_texture.jpg')
# --------------------------------------------------------------
# ----------create the base layer, base texture +base color-----
baseImage = Image(width=100, height=32, background=Color('rgb('+str(color1[0])+','+str(color1[1])+','+str(color1[2])+')'))
# print('base_color = ' + 'rgb('+str(color1[0])+','+str(color1[1])+','+str(color1[2])+')')
baseImage.composite_channel(channel='undefined', image=randomSceneImage, operator='blend', left=0, top=0)
baseImage.gaussian_blur(4, 10)
baseImage.resolution = (96, 96)
# --------------------------------------------------------------
# -----generate font--------------------------------------------
word = randomWords()
fonts = pathwalk('./fonts/font_en/')
randomFont = random.choice(fonts)
randomFont = randomFont[0] + randomFont[1]
initialPointsize = 45
draw = Drawing()
draw.font = randomFont
tmp = int(math.floor(abs(random.gauss(0, 1))*6))
if random.randint(1, 2) == 1:
rotateX = random.randint(0, tmp)
else:
rotateX = random.randint(360-tmp, 360)
draw.rotate(rotateX)
# --------------------------------------------------------------
# --------get suitable FontPointSize----------------------------
draw.font_size = initialPointsize
metric = draw.get_font_metrics(image=baseImage, text=word)
while metric.text_width > 100 or metric.text_height > 36:
initialPointsize -= 5
draw.font_size = initialPointsize
metric = draw.get_font_metrics(image=baseImage, text=word)
# --------------------------------------------------------------
# ----------italic----------------------------------------------
if random.random() > 0.5:
draw.font_style = 'italic'
# --------------------------------------------------------------
# ----------underline-------------------------------------------
if random.random() > 0.5:
draw.text_decoration = 'underline'
# --------------------------------------------------------------
# ----------gravity---------------------------------------------
draw.gravity = 'center'
# --------------------------------------------------------------
# --------------shadow/border-----------------------------------
if random.random() < 0.5:
# shadow
addx = math.ceil(random.gauss(0, 2))
addy = math.ceil(random.gauss(0, 2))
draw.fill_color = Color('black')
draw.text(x=abs(int(addx)), y=abs(int(addy)), body=word)
else:
# border
draw.stroke_color = Color('rgb('+str(color3[0])+','+str(color3[1])+','+str(color3[2])+')')
draw.stroke_width = math.ceil(initialPointsize/10)-1
# --------------------------------------------------------------
# ----------print word------------------------------------------
draw.fill_color = Color('rgb('+str(color2[0])+','+str(color2[1])+','+str(color2[2])+')')
draw.text(x=0, y=0, body=word)
draw.draw(baseImage)
# --------------------------------------------------------------
#.........这里部分代码省略.........