Пример #1
0
    def __init__(self, parent):

        # inheritance
        tk.Frame.__init__(self, parent)
        self.parent = parent

        # instantiate status
        self.sta = parent.sta
        self.sta.bind_to_interrupt(self.stop_thread)

        # instantiate config settings
        self.cfg = PlenopticamConfig()

        # instantiate menu widget
        self.men_wid = MenuWidget(self)
        self.men_wid.grid()

        # instantiate config widget
        self.fil_wid = FileWidget(self)
        self.fil_wid.grid(padx=PX, pady=PY)

        # instantiate command widget
        self.cmd_wid = CmndWidget(self)
        self.cmd_wid.grid(padx=PX, pady=PY)

        self.all_btn_list = self.cmd_wid.btn_list + self.fil_wid.btn_list + self.men_wid.btn_list

        self.var_init()
Пример #2
0
    def setUp(self):

        # set config for unit test purposes
        self.sta = PlenopticamStatus()
        self.cfg = PlenopticamConfig()
        self.cfg.reset_values()
        self.cfg.params[self.cfg.opt_dbug] = True
        self.cfg.params[self.cfg.opt_prnt] = True
Пример #3
0
    def __init__(self, *args, **kwargs):

        self.cfg = kwargs['cfg'] if 'cfg' in kwargs else PlenopticamConfig()
        self.sta = kwargs['sta'] if 'sta' in kwargs else PlenopticamStatus()

        self._bay_img = kwargs['bay_img'] if 'bay_img' in kwargs else np.array(
            [])
Пример #4
0
    def __init__(self,
                 img,
                 centroids,
                 cfg=None,
                 sta=None,
                 M=None,
                 method=None):
        """

        This class takes a list of integer coordinates as centroids and an intensity map as inputs and re-computes

        :param img: image used as basis for coordinate refinement calculation
        :param centroids: iterable (list or np.ndarray) with coordinates of integer type
        :param cfg: PlenoptiCam configuration object
        :param sta: PlenoptiCam status object
        :param M: micro image size
        :param method: 'area' or 'peak'
        """

        # input variables
        self._img = img
        self._centroids = centroids
        self.cfg = cfg if cfg is not None else PlenopticamConfig()
        self.sta = sta if sta is not None else PlenopticamStatus()
        self._M = M
        self._method = method if method is not None else 'area'

        # internal variables
        self._t = self._s = 0

        # output variables
        self._centroids_refined = []
Пример #5
0
    def __init__(self, img, centroids, cfg=None, sta=None):

        # input variables
        self._img = Normalizer(rgb2gray(img.copy())).uint8_norm()
        self._centroids = np.asarray(centroids)
        self.cfg = cfg if cfg is not None else PlenopticamConfig()
        self.sta = sta if sta is not None else PlenopticamStatus()
Пример #6
0
    def __init__(self, *args, **kwargs):

        # input variables
        self._lfp_img = kwargs['lfp_img'] if 'lfp_img' in kwargs else None
        self._wht_img = kwargs['wht_img'] if 'wht_img' in kwargs else None
        self.cfg = kwargs['cfg'] if 'cfg' in kwargs else PlenopticamConfig()
        self.sta = kwargs['sta'] if 'sta' in kwargs else misc.PlenopticamStatus()

        # convert to float
        self._lfp_img = self._lfp_img.astype('float64') if self._lfp_img is not None else None
        self._wht_img = self._wht_img.astype('float64') if self._wht_img is not None else None

        if self.cfg.calibs:
            # micro lens array variables
            self._CENTROIDS = np.asarray(self.cfg.calibs[self.cfg.mic_list])
            self._LENS_Y_MAX = int(max(self._CENTROIDS[:, 2])+1)    # +1 to account for index 0
            self._LENS_X_MAX = int(max(self._CENTROIDS[:, 3])+1)    # +1 to account for index 0

            # micro image size evaluation
            self._M = self.pitch_max(self.cfg.calibs[self.cfg.mic_list])
            self._M = self.pitch_eval(self._M, self.cfg.params[self.cfg.ptc_leng], self.sta)
            self._C = self._M//2

        try:
            self._DIMS = self._lfp_img.shape if len(self._lfp_img.shape) == 3 else self._lfp_img.shape + (1,)
        except (TypeError, AttributeError):
            pass
        except IndexError:
            self.sta.status_msg('Incompatible image dimensions: Please either use KxLx3 or KxLx1 array dimensions')
            self.sta.error = True
Пример #7
0
    def __init__(self, wht_img, cfg=None, sta=None, M=None):

        # input variables
        self._wht_img = wht_img
        self.cfg = cfg if cfg is not None else PlenopticamConfig()
        self.sta = sta if sta is not None else PlenopticamStatus()
        self._M = M
Пример #8
0
    def __init__(self, *args, **kwargs):

        self._vp_img_arr = kwargs['vp_img_arr'].astype(
            'float64') if 'vp_img_arr' in kwargs else None
        self.cfg = kwargs['cfg'] if 'cfg' in kwargs else PlenopticamConfig()
        self.sta = kwargs['sta'] if 'sta' in kwargs else PlenopticamStatus()
        self._M = self.cfg.params[self.cfg.ptc_leng]
Пример #9
0
    def __init__(self, lfp_img_align, cfg=None, sta=None):

        self._lfp_img_align = lfp_img_align
        self.cfg = cfg if cfg is not None else PlenopticamConfig()
        self.sta = sta if sta is not None else misc.PlenopticamStatus()

        # internal variable
        self._vp_img_arr = []
Пример #10
0
 def setUp(self):
     self.root = tk.Tk()
     self.cfg = PlenopticamConfig()
     self.sta = PlenopticamStatus()
     self.root.cfg = self.cfg
     self.root.sta = self.sta
     self.set_file_path()
     self.pump_events()
Пример #11
0
    def __init__(self, cfg=None, sta=None, *args, **kwargs):
        super(PropagatingThread, self).__init__(*args, **kwargs)

        # init
        self.cfg = cfg if cfg is not None else PlenopticamConfig()
        self.sta = sta if sta is not None else misc.PlenopticamStatus()
        self.exc = None
        self.ret = None
Пример #12
0
    def __init__(self, img, cfg=None, sta=None):

        # input variables
        self._img = img
        self.cfg = cfg if cfg is not None else PlenopticamConfig()
        self.sta = sta if sta is not None else PlenopticamStatus()

        # internal variable
        self._map = np.zeros(self._img.shape, dtype=self._img.dtype)
Пример #13
0
    def __init__(self, lfp_img_align=None, cfg=None, sta=None):

        # input variables
        self._lfp_img_align = lfp_img_align
        self.cfg = cfg if cfg is not None else PlenopticamConfig()
        self.sta = sta if sta is not None else misc.PlenopticamStatus()

        # variables for viewpoint arrays
        self.vp_img_arr = []        # gamma corrected
        self.vp_img_linear = []     # linear gamma (for further processing)
Пример #14
0
    def __init__(self, lfp_img, mic_list, rad=None, cfg=None, sta=None):

        # input and output variable
        self._lfp_img = lfp_img
        self.cfg = cfg if cfg is not None else PlenopticamConfig()
        self.sta = sta if sta is not None else PlenopticamStatus()

        # internal variables
        self._centroids = np.asarray(mic_list)
        self._rad = rad
Пример #15
0
    def __init__(self, img, cfg=None, sta=None, M=None):

        # input variables
        self._img = img
        self.cfg = cfg if cfg is not None else PlenopticamConfig()
        self.sta = sta if sta is not None else PlenopticamStatus()
        self._M = M if M is not None else self.cfg.params[self.cfg.ptc_leng]

        # private variables
        self._peak_img = self._img.copy()
        self._centroids = []
Пример #16
0
    def __init__(self, img, cfg, sta=None, M=None, method=None):

        # input variables
        self._img = img
        self.cfg = cfg if cfg is not None else PlenopticamConfig()
        self.sta = sta if sta is not None else PlenopticamStatus()
        self._M = M if M is not None else 9
        self._method = method if method is not None else 'area'

        # private variables
        self._peak_img = self._img.copy()
        self._centroids = []
Пример #17
0
    def setUp(self):

        # instantiate config and status objects
        self.cfg = PlenopticamConfig()
        self.cfg.default_values()
        self.sta = PlenopticamStatus()

        # enable options in config to cover more algorithms in tests
        self.cfg.params[self.cfg.cal_meth] = 'grid-fit'
        self.cfg.params[self.cfg.opt_vign] = True
        self.cfg.params[self.cfg.opt_rota] = True
        self.cfg.params[self.cfg.opt_refi] = True
        self.cfg.params[self.cfg.opt_pflu] = True
        self.cfg.params[self.cfg.opt_arti] = True
        self.cfg.params[self.cfg.opt_lier] = True
        self.cfg.params[self.cfg.opt_cont] = True
        self.cfg.params[self.cfg.opt_awb_] = True
        self.cfg.params[self.cfg.opt_sat_] = True
        self.cfg.params[self.cfg.opt_dbug] = True
        self.cfg.params[self.cfg.ran_refo] = [0, 1]

        # compute 3x3 viewpoints only (to reduce computation time)
        self.cfg.params[self.cfg.ptc_leng] = 3

        # skip progress prints (prevent Travis from terminating due to reaching 4MB logfile size)
        self.sta.prog_opt = False

        # print current process message (to prevent Travis from stopping after 10 mins)
        self.cfg.params[self.cfg.opt_prnt] = True

        # retrieve Lytro Illum data
        self.loader = DataDownloader(cfg=self.cfg, sta=self.sta)
        self.fp = join(self.loader.root_path, 'examples', 'data')
        archive_fn = join(self.fp, basename(self.loader.host_eu_url))
        self.loader.download_data(
            self.loader.host_eu_url,
            fp=self.fp) if not exists(archive_fn) else None
        self.loader.extract_archive(archive_fn)
Пример #18
0
    def __init__(self, *args, **kwargs):
        tk.Canvas.__init__(self, *args, **kwargs)
        LfpViewpoints.__init__(self, *args, **kwargs)

        # app reltated data
        self.cfg = kwargs['cfg'] if 'cfg' in kwargs else PlenopticamConfig()
        self.sta = kwargs['sta'] if 'sta' in kwargs else PlenopticamStatus()

        # window dimensions
        self._ht = self.winfo_screenheight()
        self._wd = self.winfo_screenwidth()

        # window settings
        # self['bg'] = "white"
        self.master.title("PlenoptiCam Viewer")

        vp_dirs = glob.glob(os.path.join(self.cfg.exp_path, 'viewpoints_*px'))
        rf_dirs = glob.glob(os.path.join(self.cfg.exp_path, 'refo_*px'))
        try:
            self.vp_img_arr = kwargs[
                'vp_img_arr'] if 'vp_img_arr' in kwargs else get_list(
                    vp_dirs[0], vp=1)
            self.refo_stack = kwargs[
                'refo_stack'] if 'refo_stack' in kwargs else get_list(
                    rf_dirs[0], vp=0)
        except Exception as e:
            print(e)
            self.sta.status_msg(msg='\nNo valid image data found',
                                opt=self.cfg.opt_prnt)

        if hasattr(self, 'vp_img_arr'):

            # light-field related data
            self._M = self.cfg.params[
                self.cfg.ptc_leng]  #self.vp_img_arr.shape[0]  #
            self._v = self._u = self._C = self._M // 2
            self._a = 0
            self._k = -1
            self.move_coords = self.get_move_coords(
                pattern='circle', arr_dims=self.vp_img_arr.shape[:2])

        # initialize member variables
        self.vp_mode = True
        self.auto_mode = False
        self._mode_text = tk.StringVar()
        self._mode_text.set('VP' if self.vp_mode else 'RF')
        self.all_function_trigger()

        # display initial image
        self.next_frame()
Пример #19
0
    def __init__(self, img, cfg=None, sta=None, scale_val=1.625, CR=3):

        # input variables
        self._img = img
        self.cfg = cfg if cfg is not None else PlenopticamConfig()
        self.sta = sta if sta is not None else PlenopticamStatus()
        self._scale_val = scale_val
        self._CR = CR

        # internal variables
        self._top_img = None

        # output variables
        self._M = None
        self.scale_space = []
Пример #20
0
    def __init__(self, *args, **kwargs):

        # instantiate config and status objects
        self.cfg = kwargs['cfg'] if 'cfg' in kwargs else PlenopticamConfig()
        self.sta = kwargs['sta'] if 'sta' in kwargs else PlenopticamStatus()

        # path handling: refer to folder where data will be stored
        path = kwargs['path'] if 'path' in kwargs else os.path.dirname(os.path.abspath(__file__))
        self._fp = os.path.join(path, 'data')
        self.root_path = dirname(abspath('.')) if basename((abspath('.'))) == 'tests' else abspath('.')

        # data urls
        self.host_eu_url = 'http://wp12283669.server-he.de/Xchange/illum_test_data.zip'
        self.opex_url = 'https://ndownloader.figshare.com/files/5201452'
        self.opex_fnames_wht = ['f197with4m11pxf16Final.bmp', 'f197Inf9pxFinalShift12.7cmf22.bmp']
        self.opex_fnames_lfp = ['f197with4m11pxFinal.bmp', 'f197Inf9pxFinalShift12.7cm.bmp']
Пример #21
0
    def __init__(self, centroids, cfg=None, sta=None, bbox=None):

        # input variables
        self._centroids = np.asarray(centroids)     # list of unsorted maxima
        self.cfg = cfg if cfg is not None else PlenopticamConfig()
        self.sta = sta if sta is not None else PlenopticamStatus()
        self._bbox = bbox if bbox is not None and len(bbox) == 2 else None

        # internal variables
        self._lens_x_max = None  # maximum number of "complete" micro image centers in a row
        self._lens_y_max = None  # maximum number of "complete" micro image centers in a column
        self._upper_l = None
        self._lower_r = None

        # output variables
        self._mic_list = []                     # list of micro image centers with indices assigned
        self._pattern = None                    # pattern typ of micro lens array
        self._pitch = None                      # average pitch in horizontal and vertical direction
Пример #22
0
    def __init__(self, file=None, cfg=None, sta=None, **kwargs):

        # input variables
        self.cfg = cfg if cfg is not None else PlenopticamConfig()
        self.sta = sta if sta is not None else PlenopticamStatus()
        self.file = file
        self._lfp_path = kwargs[
            'lfp_path'] if 'lfp_path' in kwargs else self.cfg.params[
                self.cfg.lfp_path]

        # internal variables
        self._json_dict = kwargs['json_dict'] if 'json_dict' in kwargs else {}
        self._shape = None
        self._img_buf = None

        # output variable
        self.cfg.lfpimg = {} if not hasattr(self.cfg,
                                            'lfpimg') else self.cfg.lfpimg
        self._bay_img = None
Пример #23
0
    def __init__(self, *args, **kwargs):

        self._vp_img_arr = kwargs['vp_img_arr'].astype(
            'float64') if 'vp_img_arr' in kwargs else None
        self.cfg = kwargs['cfg'] if 'cfg' in kwargs else PlenopticamConfig()
        self.sta = kwargs['sta'] if 'sta' in kwargs else PlenopticamStatus()
        self._M = self.cfg.params[self.cfg.ptc_leng]
        self._C = self._M // 2

        try:
            self._DIMS = self._vp_img_arr.shape if len(
                self._vp_img_arr.shape) == 3 else self._vp_img_arr.shape + (
                    1, )
        except (TypeError, AttributeError):
            pass
        except IndexError:
            self.sta.status_msg(
                'Incompatible image dimensions: Please either use KxLx3 or KxLx1 array dimensions'
            )
            self.sta.error = True
Пример #24
0
    def __init__(self, bay_img=None, wht_img=None, cfg=None, sta=None):

        # input variables
        self.cfg = cfg if cfg is not None else PlenopticamConfig()
        self.sta = sta if sta is not None else misc.PlenopticamStatus()
        self._bay_img = bay_img.astype('float32') if isinstance(
            bay_img, np.ndarray) else None
        self._wht_img = wht_img.astype('float32') if isinstance(
            wht_img, np.ndarray) else None

        self._bit_pac = self.cfg.lfpimg[
            'bit'] if 'bit' in self.cfg.lfpimg else 10
        self._gains = self.cfg.lfpimg['awb'] if 'awb' in self.cfg.lfpimg else [
            1, 1, 1, 1
        ]
        self._bay_pat = self.cfg.lfpimg[
            'bay'] if 'bay' in self.cfg.lfpimg else None

        # output variables
        self._rgb_img = np.array([])
Пример #25
0
    def __init__(self, cfg=None, sta=None):

        # input variables
        self.cfg = cfg if sta is not None else PlenopticamConfig()
        self.sta = sta if sta is not None else PlenopticamStatus()

        # internal variables
        self._lfp_json = {}
        self._georef = None
        self._lensref = None
        self._serial = None
        self._cam_model = ''
        self._cal_fn = None
        self._raw_data = None
        self._file_found = None
        self._opt_prnt = True if sta is not None else self.cfg.params[
            self.cfg.opt_prnt]
        self._path = self.cfg.params[self.cfg.cal_path]

        # output variables
        self._wht_bay = None
Пример #26
0
    def __init__(self, *args, **kwargs):

        # input variables
        self._lfp_img = kwargs['lfp_img'] if 'lfp_img' in kwargs else None
        self._wht_img = kwargs['wht_img'] if 'wht_img' in kwargs else None
        self.cfg = kwargs['cfg'] if 'cfg' in kwargs else PlenopticamConfig()
        self.sta = kwargs['sta'] if 'sta' in kwargs else PlenopticamStatus()

        # add 3rd axis for 2D image
        self._lfp_img = self._lfp_img[..., np.newaxis] if len(self._lfp_img.shape) == 2 else self._lfp_img

        # convert to float
        self._lfp_img = self._lfp_img.astype('float64')
        self._wht_img = self._wht_img.astype('float64')

        self._CENTROIDS = np.asarray(self.cfg.calibs[self.cfg.mic_list])
        self._M = LfpCropper.pitch_max(self.cfg.calibs[self.cfg.mic_list])
        self._C = int((self._M-1)/2)
        self._LENS_Y_MAX = int(max(self._CENTROIDS[:, 2]))
        self._LENS_X_MAX = int(max(self._CENTROIDS[:, 3]))
        self._DIMS = self._lfp_img.shape if len(self._lfp_img.shape) == 3 else None
Пример #27
0
    def __init__(self, *args, **kwargs):

        # input variables
        self._lfp_img = kwargs['lfp_img'] if 'lfp_img' in kwargs else None
        self._wht_img = kwargs['wht_img'] if 'wht_img' in kwargs else None
        self.cfg = kwargs['cfg'] if 'cfg' in kwargs else PlenopticamConfig()
        self.sta = kwargs[
            'sta'] if 'sta' in kwargs else misc.PlenopticamStatus()

        # convert to float
        self._lfp_img = self._lfp_img.astype(
            'float64') if self._lfp_img is not None else None
        self._wht_img = self._wht_img.astype(
            'float64') if self._wht_img is not None else None

        # micro lens array variables
        self._CENTROIDS = np.asarray(self.cfg.calibs[self.cfg.mic_list])
        self._LENS_Y_MAX = int(max(self._CENTROIDS[:, 2]) +
                               1)  # +1 to account for index 0
        self._LENS_X_MAX = int(max(self._CENTROIDS[:, 3]) +
                               1)  # +1 to account for index 0

        # micro image size evaluation
        self._M = self.pitch_max(self.cfg.calibs[self.cfg.mic_list])
        self._M = self.pitch_eval(self._M, self.cfg.params[self.cfg.ptc_leng],
                                  self.sta)
        self._C = self._M // 2

        if self._lfp_img is not None:

            # get light field dimensions
            self._DIMS = self._lfp_img.shape

            # add 3rd axis for 2D image
            self._lfp_img = self._lfp_img[..., np.newaxis] if len(
                self._lfp_img.shape) == 2 else self._lfp_img
Пример #28
0
import numpy as np

from plenopticam.cfg import PlenopticamConfig
cfg = PlenopticamConfig()
cfg.params[cfg.cal_meta] = ""
cfg.load_cal_data()
mic_list = np.asarray(cfg.calibs[cfg.mic_list])

from plenopticam.misc import PlenopticamStatus
sta = PlenopticamStatus()

# do grid fitting
from plenopticam.lfp_calibrator import GridFitter
obj = GridFitter(cfg=cfg, sta=sta)
obj.main()
new_list = np.asarray(obj.grid_fit)

# plot
import matplotlib.pyplot as plt
plt.figure()
plt.plot(mic_list[:, 1], mic_list[:, 0], 'rx')
plt.plot(new_list[:, 1], new_list[:, 0], 'b+')
plt.show()
Пример #29
0
def main():

    # program info
    print("\nPlenoptiCam v%s \n" % __version__)

    # create config object
    cfg = PlenopticamConfig()
    cfg.default_values()

    # parse options
    cfg = parse_options(sys.argv[1:], cfg)

    # instantiate status object
    sta = misc.PlenopticamStatus()
    sta.bind_to_interrupt(sys.exit)  # set interrupt

    # force relative paths to be absolute
    cfg.params[cfg.lfp_path] = os.path.abspath(cfg.params[cfg.lfp_path])
    cfg.params[cfg.cal_path] = os.path.abspath(cfg.params[cfg.cal_path])

    # collect light field image file name(s) based on provided path
    if os.path.isdir(cfg.params[cfg.lfp_path]):
        lfp_filenames = [
            f for f in os.listdir(cfg.params[cfg.lfp_path])
            if f.lower().endswith(SUPP_FILE_EXT)
        ]
        cfg.params[cfg.lfp_path] = os.path.join(cfg.params[cfg.lfp_path],
                                                'dummy.ext')
    elif not os.path.isfile(cfg.params[cfg.lfp_path]):
        lfp_filenames = [
            misc.select_file(cfg.params[cfg.lfp_path],
                             'Select plenoptic image')
        ]
    else:
        lfp_filenames = [cfg.params[cfg.lfp_path]]

    if not cfg.params[cfg.cal_path]:
        # manual calibration data selection
        sta.status_msg(
            '\r Please select white image calibration source manually',
            cfg.params[cfg.opt_prnt])
        # open selection window (at current lfp file directory) to set calibration folder path
        cfg.params[cfg.cal_path] = misc.select_file(
            cfg.params[cfg.lfp_path], 'Select calibration image')

    # provide number of found images to user
    print("\n %s Image(s) found" % len(lfp_filenames))

    # cancel if file paths not provided
    sta.validate(checklist=lfp_filenames + [cfg.params[cfg.lfp_path]],
                 msg='Canceled due to missing image file path')

    # iterate through light field image(s)
    for lfp_filename in sorted(lfp_filenames):

        # change path to next filename
        cfg.params[cfg.lfp_path] = os.path.join(
            os.path.dirname(cfg.params[cfg.lfp_path]), lfp_filename)
        print(cfg.params[cfg.lfp_path])
        sta.status_msg(msg='Process file ' + lfp_filename,
                       opt=cfg.params[cfg.opt_prnt])

        # remove output folder if option is set
        misc.rmdir_p(cfg.exp_path) if cfg.params[cfg.dir_remo] else None

        try:
            # decode light field image
            lfp_obj = lfp_reader.LfpReader(cfg, sta)
            lfp_obj.main()
            lfp_img = lfp_obj.lfp_img
            del lfp_obj
        except Exception as e:
            misc.PlenopticamError(e)
            continue
        # create output data folder
        misc.mkdir_p(cfg.exp_path, cfg.params[cfg.opt_prnt])

        if cfg.cond_auto_find():
            # automatic calibration data selection
            obj = lfp_calibrator.CaliFinder(cfg, sta)
            obj.main()
            wht_img = obj.wht_bay
            del obj

        else:
            # load white image calibration file
            wht_img = misc.load_img_file(cfg.params[cfg.cal_path])
            # save settings configuration
            cfg.save_params()

        # perform calibration if previously computed calibration data does not exist
        meta_cond = not (os.path.exists(cfg.params[cfg.cal_meta])
                         and cfg.params[cfg.cal_meta].lower().endswith('json'))
        if meta_cond or cfg.params[cfg.opt_cali]:
            # perform centroid calibration
            cal_obj = lfp_calibrator.LfpCalibrator(wht_img, cfg, sta)
            cal_obj.main()
            cfg = cal_obj.cfg
            del cal_obj

        # load calibration data
        cfg.load_cal_data()

        #  check if light field alignment has been done before
        if cfg.cond_lfp_align():
            # align light field
            lfp_obj = lfp_aligner.LfpAligner(lfp_img, cfg, sta, wht_img)
            lfp_obj.main()
            lfp_obj = lfp_obj.lfp_img
            del lfp_obj

        # load previously computed light field alignment
        with open(os.path.join(cfg.exp_path, 'lfp_img_align.pkl'), 'rb') as f:
            lfp_img_align = pickle.load(f)

        # extract viewpoint data
        lfp_calibrator.CaliFinder(cfg).main()
        obj = lfp_extractor.LfpExtractor(lfp_img_align, cfg=cfg, sta=sta)
        obj.main()
        vp_img_arr = obj.vp_img_arr
        del obj

        # do refocusing
        if cfg.params[cfg.opt_refo]:
            obj = lfp_refocuser.LfpRefocuser(vp_img_arr, cfg=cfg, sta=sta)
            obj.main()
            del obj

    return True
Пример #30
0
from plenopticam.misc import PlenopticamStatus, load_img_file
from plenopticam.cfg import PlenopticamConfig, constants

import numpy as np
import matplotlib.pyplot as plt
from color_space_converter import rgb2gry

# Text rendering with LaTeX
from matplotlib import rc
rc('font', **{'family': 'sans-serif', 'sans-serif': ['Helvetica']})
rc('text', usetex=True)
# for Palatino
# rc('font',**{'family':'serif','serif':['Palatino']})

# plenopticam objects
cfg = PlenopticamConfig()
sta = PlenopticamStatus()

# file settings
fname = './c'
cfg.params[cfg.cal_path] = fname + '.png'
cfg.params[cfg.cal_meth] = constants.CALI_METH[2]  #'peak'   #
wht_img = load_img_file(cfg.params[cfg.cal_path])
crop = True

# load ground truth (remove outlying centers)
spots_grnd_trth = np.loadtxt(fname + '.txt')
spots_grnd_trth = spots_grnd_trth[spots_grnd_trth[:, 1] > 0]
spots_grnd_trth = spots_grnd_trth[spots_grnd_trth[:, 0] > 0]
spots_grnd_trth = spots_grnd_trth[spots_grnd_trth[:, 1] < wht_img.shape[1]]
spots_grnd_trth = spots_grnd_trth[spots_grnd_trth[:, 0] < wht_img.shape[0]]