Beispiel #1
0
    print('\nNormalising csvs...')
    for index, file in enumerate(data_files):
        file_path = os.path.join(img_dir, file)
        img, file_name = io.csv_in(file_path=file_path)

        _, img_no = file_name.split('_')
        io.png_out(image_data=img,
                   file_name=file_name,
                   dir_name=img_dir,
                   image_title=f'Image: {img_no}',
                   out_name=f'{file_name}.png',
                   plot_show=False)

        norm_img = dp.pwr_norm(image_data=img,
                               file_name=file_name,
                               norm_power=norm_power,
                               dir_name=img_dir)

        io.png_out(image_data=norm_img,
                   file_name=file_name,
                   dir_name=img_dir,
                   image_title=f'Normalised image: {img_no}',
                   out_name=f'corrected_{file_name}.png',
                   plot_show=False)

        io.array_out(array_name=norm_img,
                     file_name=f'corrected_{file_name}',
                     dir_name=os.path.join(img_dir, 'corrected_imgs'))

        io.update_progress(index / len(data_files))
Beispiel #2
0
main_dir = io.config_dir_path()

exp_settings = io.exp_in(main_dir)
print(f'Experiment Settings:\n {exp_settings}\n')

for hs_img in exp_settings['hs_imgs']:
    img_dir = os.path.join(main_dir, hs_img)
    if not os.path.isdir(img_dir):
        continue
    corrected_img_dir = os.path.join(img_dir, 'corrected_imgs')

    data_files = io.extract_files(dir_name=corrected_img_dir,
                                  file_string='corrected_img_')
    print(len(data_files))

    data_cube = []

    print('\nBuilding data cube...')
    for index, file in enumerate(data_files):
        file_path = os.path.join(corrected_img_dir, file)
        corrected_img, file_name = io.array_in(file_path, mode='r')
        data_cube.append(corrected_img)

        io.update_progress(index / len(data_files))

    print('\nSaving data cube...approximately 1min per 100 imgs')
    io.array_out(array_name=data_cube,
                 file_name=f'{hs_img}_datacube',
                 dir_name=main_dir)
Beispiel #3
0
            norm_img = dp.pwr_norm(image_data=img,
                                   file_name=file_name,
                                   norm_power=norm_power,
                                   dir_name=img_dir)

            if norm_save:
                io.png_out(image_data=norm_img,
                           file_name=file_name,
                           dir_name=img_dir,
                           image_title=f'Normalised image: {img_no}',
                           out_name=f'corrected_{file_name}.png',
                           plot_show=False)

            io.array_out(array_name=norm_img,
                         file_name=f'corrected_{file_name}',
                         dir_name=os.path.join(img_dir, 'corrected_imgs'))

            io.update_progress(index / len(data_files))

    if datacube:
        data_files = io.extract_files(dir_name=corrected_img_dir,
                                      file_string='corrected_img_')

        data_cube = []
        print(f'\nBuilding data cube for {hs_img}...')
        for index, file in enumerate(data_files):
            file_path = os.path.join(corrected_img_dir, file)

            corrected_img, file_name = io.array_in(file_path, mode='r')
            data_cube.append(corrected_img)