Ejemplo n.º 1
0
def main_synchrotron(edge_size=400):
    # ============= Обработка синхротронных данных =====================
    # для неоцентрированных образцов
    sample_crop_edges = {
        '123493': (None, None),
        '123494': (400, 1800),
        '123495': (None, None),
        '123496': (1200, 2100),
        '123497': (None, None),
        '123498': (1000, 1900)
    }
    file_id = '123498'
    # for file_id in sample_crop_edges.keys():
    # забираем уже отбинаризованый образец с папки database
    bin_img = get_bin_img(file_id + '.h5').astype(bool)

    # обрезаем картинку
    left_edge, right_edge = sample_crop_edges[file_id]
    if left_edge and right_edge:
        bin_img = bin_img[:, left_edge:right_edge, :]

    # наризаем на кубики, показываем это на первом слое (сечении) и строим гистограмму
    img_fragments = divide_image_into_cubic_fragments(bin_img,
                                                      edge_size=edge_size)
    save_first_section_of_img(bin_img, file_id, edge_size)

    get_porosity_histogram_disrtibution(img_fragments, file_id, bin_img.shape,
                                        PIXEL_SIZE_MM_SYNCHROTRON)
Ejemplo n.º 2
0
def calc_histograms_lab_setups():
    for polimer_type in ["PDL-05", "PDLG-5002"]:
        radius_coefs = {"PDL-05": 0.9, "PDLG-5002": 0.95}

        paths = file_paths.get_benchtop_setup_paths(polimer_type)

        for sample_id in range(len(paths)):
            sample_name = list(paths.keys())[sample_id]
            print(
                f"============== {sample_id} sample: {sample_name} =============="
            )

            img3d = get_bin_img(sample_name)
            print('tot: ', np.sum(img3d) / img3d.size)

            fig, ax = plt.subplots()
            ax.imshow(img3d[0], cmap="gray")
            dm.save_plot(fig, "previews", f'{sample_id} bin ' + sample_name)

            cylindric_fragments, cylindric_masks \
                = divide_image_into_sector_cylindric_fragments(img3d,
                                                                height=len(img3d)//3-1,
                                                                radius_coef=radius_coefs[polimer_type])

            fig = get_porosity_histogram_disrtibution(
                cylindric_fragments,
                sample_name,
                img3d.shape,
                pixel_size_mm=PIXEL_SIZE_MM_SETUP,
                masks=cylindric_masks,
                radius_coef=radius_coefs[polimer_type])

            dm.save_plot(fig, SAVE_IMG_DESKTOP_SETUP_FOLDER,
                         f'hist {sample_id} {sample_name}')
Ejemplo n.º 3
0
if __name__ == '__main__':

    polimer_type = ["PDL-05", "PDLG-5002"][0]
    radius_coefs = {"PDL-05": 0.9, "PDLG-5002": 0.95}

    paths = file_paths.get_benchtop_setup_paths(polimer_type)
    df = dm.load_data("setup_culindric_porosities.csv")
    #df =  pd.DataFrame(columns = ['polimer_type', 'sample_number', 'date', 'mean', 'std'])

    for sample_id in range(len(paths)):
        sample_name = list(paths.keys())[sample_id]
        print(
            f"============== {sample_id} sample: {sample_name} ==============")
        print(sample_name.split())

        img3d = ~get_bin_img(sample_name)
        print('tot: ', np.sum(img3d) / img3d.size)

        fig, ax = plt.subplots()
        ax.imshow(img3d[0], cmap="gray")
        dm.save_plot(fig, "previews", f'{sample_id} bin ' + sample_name)

        cylindric_fragments, cylindric_masks \
            = divide_image_into_sector_cylindric_fragments(img3d,
                                                        height=len(img3d)//3-1,
                                                        radius_coef=radius_coefs[polimer_type])

        std, mean = get_mean_porosity_and_std(cylindric_fragments,
                                              cylindric_masks)

        data_info = sample_name.split()