individual.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:PolyPic 作者: Alfo5123 项目源码 文件源码
def generate( self ):

        # Create black background image and fill it up with random polygons

        img = np.zeros((self.height, self.width, 3), np.uint8)

        overlay = img.copy()
        output = img.copy()

        for i in range(self.size):

            info = self.genes[i].getInfo()

            if self.type == 1:

                cv2.circle(overlay,info[0],  info[1], info[2], -1)
                cv2.addWeighted(overlay, info[3], output, 1 - info[3], 0, output)

            elif self.type == 2:

                cv2.ellipse(overlay,info[0],info[1],info[2],0,360,info[3],-1)
                cv2.addWeighted(overlay, info[4], output, 1 - info[4], 0, output)

            elif self.type == 3:

                cv2.fillConvexPoly(overlay,np.asarray(info[0]), info[1])
                cv2.addWeighted(overlay, info[2], output, 1 - info[2], 0, output)

            elif self.type == 4:

                cv2.fillConvexPoly(overlay, np.asarray(info[0]), info[1])
                cv2.addWeighted(overlay, info[2], output, 1 - info[2], 0, output  )

        return output
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号