generator.py 文件源码

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

项目:panda3d-mapzen 作者: sanguinariojoe 项目源码 文件源码
def set_rocks_in_grad(self, elevation, landcover):
        """ Modify the land cover to create rocks in the large gradient pixels
        (large steepness)

        Position arguments:
        elevation -- Elevation image
        landcover -- Landcover to become edited

        Returned value:
        Edited landcover
        """
        # Compute the steepness of each pixel
        grad = gaussian_gradient_magnitude(elevation, 1.0)
        grad /= self.mercator.Resolution(self.__zoom)
        # Get the mask of rock (with a smooth transition)
        mask = (grad >= ROCK_STEEPNESS).astype(np.float)
        mask = gaussian_filter(mask, 3.0)
        # Blend the images
        dtype = landcover.dtype
        rock_image = np.zeros(landcover.shape, dtype=dtype)
        rock_image[:,:] = ROCK_COLOR
        for i in range(3):
            rock_image[:,:,i] = (mask * rock_image[:,:,i]).astype(dtype)
            landcover[:,:,i] = ((1.0 - mask) * landcover[:,:,i]).astype(dtype)
        landcover += rock_image
        return landcover
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号