Пример #1
0
        HDF5Datas = []
        HDF5Labels = []

        # Read reference image
        ReferenceName = args.reference[i]
        print '================================================================'
        print 'Processing image : ', ReferenceName
        # Read NIFTI
        ReferenceNifti = sitk.ReadImage(ReferenceName)

        # Get data from NIFTI
        ReferenceImage = np.swapaxes(sitk.GetArrayFromImage(ReferenceNifti), 0,
                                     2).astype('float32')

        # Normalization
        ReferenceImage = imadjust3D(ReferenceImage, [0, 1])

        # ===== Generate input LR image =====
        # Blurring
        BlurReferenceImage = scipy.ndimage.filters.gaussian_filter(
            ReferenceImage, sigma=args.sigma)

        for scale in args.scale:
            print 'With respect to scale factor x', scale, ' : '

            # Modcrop to scale factor
            BlurReferenceImage = modcrop3D(BlurReferenceImage, scale)
            ReferenceImage = modcrop3D(ReferenceImage, scale)

            # Downsampling
            LowResolutionImage = scipy.ndimage.zoom(
Пример #2
0
        print '================================================================'
        print 'Processing (label) reference image : ', ReferenceName
        print 'Processing input image : ', InputName

        # Read NIFTI
        ReferenceNifti = sitk.ReadImage(ReferenceName)
        InputNifti = sitk.ReadImage(InputName)

        # Get data from NIFTI
        ReferenceImage = np.swapaxes(sitk.GetArrayFromImage(ReferenceNifti), 0,
                                     2).astype('float32')
        InputImage = np.swapaxes(sitk.GetArrayFromImage(InputNifti), 0,
                                 2).astype('float32')

        # Normalization
        ReferenceImage = imadjust3D(ReferenceImage, [0, 1])
        InputImage = imadjust3D(InputImage, [0, 1])

        # Compute scale factor:
        TargetShape = ReferenceImage.shape
        InputShape = InputImage.shape
        scale = (Targetidx / inputidx
                 for Targetidx, inputidx in zip(TargetShape, InputShape))
        print 'With respect to scale factor x', scale

        # Cubic Interpolation
        if TargetShape != InputShape:
            InputImage = scipy.ndimage.zoom(InputImage,
                                            zoom=scale,
                                            order=args.order)
Пример #3
0
        print '================================================================'
        print 'Processing image : ', ReferenceName
        print 'Intermodality image : ', IntermodalityName

        # Read NIFTI
        ReferenceNifti = sitk.ReadImage(ReferenceName)
        IntermodalityNifti = sitk.ReadImage(IntermodalityName)

        # Get data from NIFTI
        ReferenceImage = np.swapaxes(sitk.GetArrayFromImage(ReferenceNifti), 0,
                                     2).astype('float32')
        IntermodalityImage = np.swapaxes(
            sitk.GetArrayFromImage(IntermodalityNifti), 0, 2).astype('float32')

        # Normalization
        ReferenceImage = imadjust3D(ReferenceImage, [0, 1])
        IntermodalityImage = imadjust3D(IntermodalityImage, [0, 1])

        # ===== Generate input LR image =====
        # Blurring
        BlurReferenceImage = scipy.ndimage.filters.gaussian_filter(
            ReferenceImage, sigma=args.sigma)

        for scale in args.scale:
            print 'With respect to scale factor x', scale, ' : '

            # Modcrop to scale factor
            BlurReferenceImage = modcrop3D(BlurReferenceImage, scale)
            ReferenceImage = modcrop3D(ReferenceImage, scale)

            # Downsampling