objects.py 文件源码

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

项目:prysm 作者: brandondube 项目源码 文件源码
def from_file(path, scale):
        ''' Reads a file into a new RGBImage instance, must be 24bpp/8bpc

        Args:
            path (`string`): path to a file.

            scale (`float`): pixel scale, in microns.

        Returns:
            `RGBImage`: a new image object.

        Notes:
            TODO: proper handling of images with more than 8bpp.
        '''
        # img is an mxnx3 array of unit8s
        img = imread(path).astype(config.precision) / 255

        img = np.flip(img, axis=0)

        # crop the image if it has an odd dimension.
        # TODO: change this an understand why it is an issue
        # fftshift vs ifftshift?
        if is_odd(img.shape[0]):
            img = img[0:-1, :, :]
        if is_odd(img.shape[1]):
            img = img[:, 0:-1, :]
        return RGBImage(r=img[:, :, 0], g=img[:, :, 1], b=img[:, :, 2],
                        sample_spacing=scale, synthetic=False)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号