patch_extractor_edges.py 文件源码

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

项目:nn-segmentation-for-lar 作者: cvdlab 项目源码 文件源码
def __init__(self, num_samples=None, path_to_images=None, sigma=None,
                 patch_size=(23, 23),
                 augmentation_angle=0):
        """
        load and store all necessary information to achieve the patch extraction
        :param num_samples: number of patches required
        :param path_to_images: path to the folder containing all '.png.' files
        :param sigma: sigma value to apply at the canny filter for patch extraction criteria
        :param patch_size: dimensions for each patch
        :param augmentation_angle: angle necessary to operate the increase of the number of patches
        """
        print( '*' * 50 )
        print( 'Starting patch extraction...' )
        # inserire il check per sigma
        if sigma is None:
            print( " missing threshold value, impossible to proceed" )
            exit( 1 )
        if path_to_images is None:
            ValueError( 'no destination file' )
            exit( 1 )
        if num_samples is None:
            ValueError( 'specify the number of patches to extract and reload class' )
            exit( 1 )
        self.sigma = sigma
        self.augmentation_angle = augmentation_angle % 360
        self.images = np.array( [rgb2gray( imread( path_to_images[el] ).astype( 'float' ).reshape( 5, 216, 160 )[-2] )
                                 for el in range( len( path_to_images ) )] )
        if self.augmentation_angle is not 0:
            self.augmentation_multiplier = int( 360. / self.augmentation_angle )
        else:
            self.augmentation_multiplier = 1

        self.num_samples = num_samples

        self.patch_size = patch_size
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号