Esempio n. 1
0
    def init_paths(self, data_name, path, N_distances, first_distance=1):
        """Generate paths images & flatfields"""

        #set data_names
        data_names, ff_names = init_names(data_name,
                                          N_distances,
                                          first_distance=first_distance)

        #find images
        imlist = var.im_folder(path)

        #set proper paths
        images = np.zeros(N_distances, 'object')
        flats = np.zeros(N_distances, 'object')

        for i in np.arange(len(images)):
            #sort image paths
            images[i] = [
                path + im for im in imlist
                if (im.startswith(data_names[i])) and not (im.startswith('.'))
            ]
            flats[i] = [
                path + im for im in imlist if im.startswith(ff_names[i])
            ]

        self.images = images
        self.flats = flats
Esempio n. 2
0
    def init_paths(self, data_name, path, **kwargs):
        """Generate paths images & flatfields"""

        #set variables
        param = Processor().init_parameters(**kwargs)

        if 'N_distances' in self.__dict__:
            N_distances = self.N_distances
        else:
            N_distances = param['N_distances']

        #set data_names
        data_names, ff_names = Processor().init_names(data_name, N_distances)

        #find images
        imlist = var.im_folder(path)

        #set proper paths
        images = np.zeros(N_distances, 'object')
        flats = np.zeros(N_distances, 'object')

        for i in np.arange(len(images)):
            #sort image paths
            images[i] = [
                path + im for im in imlist
                if (im.startswith(data_names[i])) and not (im.startswith('.'))
            ]
            flats[i] = [
                path + im for im in imlist if im.startswith(ff_names[i])
            ]

        self.images = images
        self.flats = flats
Esempio n. 3
0
    def init_paths(self, data_name, path, distance_indexes):
        """Generate paths images & flatfields"""

        #set data_names
        data_names, ff_names = init_names_custom(
            data_name=data_name, distance_indexes=distance_indexes)

        #find images
        imlist = var.im_folder(path)

        # create a filter for unnecessary images
        tail = '_00000.tiff'

        if len(data_names[0]) != len(data_names[-1]):
            print("""
            WARNING! Different distances in your dataset 
            have different naming lengths. 
            File names can't be arranged. 
            Try to reduce the number of distances (<10) or modify the script.
            """)
            sys.exit()
        else:
            data_lencheck = len(data_names[0] + tail)
            ff_lencheck = len(ff_names[0] + tail)

        #set proper paths
        N_distances = len(distance_indexes)
        images = np.zeros(N_distances, 'object')
        flats = np.zeros(N_distances, 'object')

        for i in np.arange(len(images)):

            #sort image paths
            images[i] = [
                path + im for im in imlist if (im.startswith(data_names[i]))
                and not (im.startswith('.')) and (len(im) == data_lencheck)
            ]

            flats[i] = [
                path + im for im in imlist
                if im.startswith(ff_names[i]) and (len(im) == ff_lencheck)
            ]

        self.images = images
        self.flats = flats
Esempio n. 4
0
#set the ROI of image first, the logic corresponds to FIJI (to be read (x,y,x1,y1 at the image - inverse to numpy!)
ROI = (0, 0, 2048, 2048)

folder = '/Users/au704469/Documents/Postdoc/Results/X-ray_tomography/Brain_organoid_P14_DESY_Nov2020/Data_test/144mm/'

image_name = 'try0_full_144mm_1_00001.tiff'

#let's read the image and crop it
image = tifffile.imread(folder + image_name)
image = image[ROI[1]:ROI[3], ROI[0]:ROI[2]]

# now let's read all flatfield files from the folder
# in our case flatfield files start with the prefix 'ff_'

#create the list all images in the folder
imlist = var.im_folder(folder)

#read ff-files
flatfield = np.asarray([
    tifffile.imread(folder + im) for im in imlist
    if im.startswith('ff_' + image_name)
])
flatfield = flatfield[:, ROI[1]:ROI[3], ROI[0]:ROI[2]]

# please transpose the ff-array for the further ff-correction
flatfield = np.transpose(flatfield, (1, 2, 0))

# let's divide our image by the flatfield, using SSIM metrix

# images should be set as special classes:
image_class = SSIM.SSIM_const(image)