本文整理汇总了Python中picture.Picture.get方法的典型用法代码示例。如果您正苦于以下问题:Python Picture.get方法的具体用法?Python Picture.get怎么用?Python Picture.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类picture.Picture
的用法示例。
在下文中一共展示了Picture.get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Picture
# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import get [as 别名]
import sys
import stddraw
import luminance
from picture import Picture
#-----------------------------------------------------------------------
# Accept the name of a JPG or PNG file as a command-line argument.
# Read an image from the file with that name. Create and show a
# gray scale version of that image.
pic = Picture(sys.argv[1])
for col in range(pic.width()):
for row in range(pic.height()):
pixel = pic.get(col, row)
gray = luminance.toGray(pixel)
pic.set(col, row, gray)
stddraw.setCanvasSize(pic.width(), pic.height())
stddraw.picture(pic)
stddraw.show()
#-----------------------------------------------------------------------
# python grayscale.py mandrill.jpg
# python grayscale mandrill.png
# python grayscale.py darwin.jpg
示例2: int
# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import get [as 别名]
# Accept the name of a JPG or PNG image file, an integer w, and
# an integer h as command line arguments. Read an image from the
# file, and display the image scaled to width w and height h.
fileName = sys.argv[1]
w = int(sys.argv[2])
h = int(sys.argv[3])
source = Picture(fileName)
target = Picture(w, h)
for tCol in range(w):
for tRow in range(h):
sCol = tCol * source.width() // w
sRow = tRow * source.height() // h
target.set(tCol, tRow, source.get(sCol, sRow))
stddraw.setCanvasSize(w, h)
stddraw.picture(target)
stddraw.show()
#-----------------------------------------------------------------------
# python scale.py mandrill.jpg 800 800
# python scale.py mandrill.jpg 600 300
# python scale.py mandrill.jpg 200 400
# python scale.py mandrill.jpg 200 200
示例3: int
# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import get [as 别名]
n = int(sys.argv[3]) # number of intermediate frames
source = Picture(sourceFile)
target = Picture(targetFile)
width = source.width()
height = source.height()
stddraw.setCanvasSize(width, height)
pic = Picture(width, height)
for t in range(n+1):
for col in range(width):
for row in range(height):
c0 = source.get(col, row)
cn = target.get(col, row)
alpha = float(t) / float(n)
c = blend(c0, cn, alpha)
pic.set(col, row, c)
stddraw.picture(pic)
stddraw.show(1000.0)
stddraw.show()
#-----------------------------------------------------------------------
# python fade.py mandrill.jpg darwin.jpg 7
# python fade.py mandrill.jpg darwin.jpg 5