当前位置: 首页>>代码示例>>Python>>正文


Python Lib.to2d方法代码示例

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


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

示例1: applyFilter

# 需要导入模块: import Lib [as 别名]
# 或者: from Lib import to2d [as 别名]
 def applyFilter(self, aImage):
     oldtime = time.time()
     # intialize a new filtered image
     new_image = Image.new('RGB', aImage.size)
     new_image_list = []
     #get the pixels list from the original image
     #pixels = aImage.getdata()
     
     pixels = Lib.to2d(aImage)
     
     height = len(pixels)
     width = len(pixels[0])
     
     print height, width
     n = 0
     p = 1
     for x in range(width):
         for y in range(height):
             
             r = int(pixels[y][x][0]*self.amount)
             g = int(pixels[y][x][1]*self.amount)
             b = int(pixels[y][x][2]*self.amount)
             
             if Lib.isprime(n):
                 r=g=b=0
                 p+=1
             
             new_pixel = (r,g,b)
             new_image_list.append(new_pixel)
             n+=1
             
     new_image.putdata(new_image_list)
     timetaken = time.time()-oldtime
     print "primes:", n-p, ", out of", n , "pixels", ", it took", timetaken, "seconds"
     return new_image
开发者ID:Cheesier,项目名称:Instapy,代码行数:37,代码来源:CFilterTest.py

示例2: applyFilter

# 需要导入模块: import Lib [as 别名]
# 或者: from Lib import to2d [as 别名]
 def applyFilter(self, aImage):
     # intialize a new filtered image
     new_image = Image.new('RGB', aImage.size)
     new_image_list = []
     #get the pixels list from the original image
     #pixels = aImage.getdata()
     
     pixels = Lib.to2d(aImage)
     
     height = len(pixels)
     width = len(pixels[0])
     
     for x in range(width):
         for y in range(height):
                 
             if x > self.size and x < (width - self.size) and \
             y > self.size and y < (height - self.size):
                 r = int(pixels[y][x][0])
                 g = int(pixels[y][x][1])
                 b = int(pixels[y][x][2])
             else:
                 r = int(self.color[0]*255)
                 g = int(self.color[1]*255)
                 b = int(self.color[2]*255)
             
             new_pixel = (r,g,b)
             new_image_list.append(new_pixel)
             
     new_image.putdata(new_image_list)
     return new_image
开发者ID:Cheesier,项目名称:Instapy,代码行数:32,代码来源:CFilterPlainBorder.py

示例3: applyFilter

# 需要导入模块: import Lib [as 别名]
# 或者: from Lib import to2d [as 别名]
 def applyFilter(self, aImage):
     # intialize a new filtered image
     new_image = Image.new('RGB', aImage.size)
     new_image_list = []
     #get the pixels list from the original image
     #pixels = aImage.getdata()
     
     pixels = Lib.to2d(aImage)
     
     height = len(pixels)
     width = len(pixels[0])
     
     hardness = 1
     
     for x in range(width):
         for y in range(height):
             
             dist = Lib.distanceFromPoint(x, y, width/2, height/2) / math.sqrt((width/2)**2 + (height/2)**2)
             
             r = int(pixels[y][x][0]*(self.amount-dist))
             g = int(pixels[y][x][1]*(self.amount-dist))
             b = int(pixels[y][x][2]*(self.amount-dist))
             
             #r = int(r**hardness)
             #g = int(g**hardness)
             #b = int(b**hardness)
             
             new_image_list.append((r,g,b))
             
     new_image.putdata(new_image_list)
     return new_image
开发者ID:Cheesier,项目名称:Instapy,代码行数:33,代码来源:CFilterVignette.py


注:本文中的Lib.to2d方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。