In [ ]:
import os
import sys
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from matplotlib import gridspec
import glob
from PIL import Image
%matplotlib notebook
In [2]:
root_folder = os.path.dirname(os.getcwd())
sys.path.append(root_folder)
import NeuNorm as neunorm
from NeuNorm.normalization import Normalization
from NeuNorm.roi import ROI
In [10]:
path_ob = os.path.abspath('../data/ob/')
list_open_beam = glob.glob(os.path.join(path_ob, '*.tif'))
ob_data = []
for _file in list_open_beam:
    _ob_data = np.asarray(Image.open(_file))
    ob_data.append(_ob_data)
In [11]:
path_im = '../data/sample'
list_sample = glob.glob(os.path.join(path_im, '*.tif'))
sample_data = []
for _file in list_sample:
    _sample_data = np.asarray(Image.open(_file))
    sample_data.append(_sample_data)
In [12]:
path_df = '../data/df'
list_df = glob.glob(os.path.join(path_df, '*.tif'))
df_data = []
for _file in list_df:
    _df_data = np.asarray(Image.open(_file))
    df_data.append(_df_data)
In [16]:
o_norm = Normalization()
o_norm.load(data=sample_data)
o_norm.load(data=ob_data, data_type='ob')
o_norm.load(data=df_data, data_type='df')
In [17]:
o_norm.df_correction()
In [18]:
norm_roi = ROI(x0=3, y0=5, width=20, height=40)
o_norm.normalization(roi=norm_roi)
Out[18]:
True
In [19]:
normalized_data = o_norm.data['normalized']
In [20]:
np.shape(normalized_data)
Out[20]:
(15, 100, 100)
In [21]:
roi_to_keep = ROI(x0=0, y0=0, width=2, height=2)
o_norm.crop(roi=roi_to_keep)

norm_crop = o_norm.data['normalized']
np.shape(norm_crop)
Out[21]:
(15, 3, 3)
In [ ]:

In [ ]: