How to use the plenopticam.lfp_extractor.LfpViewpoints function in plenopticam

To help you get started, we’ve selected a few plenopticam examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hahnec / plenopticam / plenopticam / gui / ple_viewer.py View on Github external
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:
github hahnec / plenopticam / plenopticam / gui / widget_view.py View on Github external
def __init__(self, *args, **kwargs):

        # use button status for enabling/disabling purposes
        self.btn = kwargs['btn'] if 'btn' in kwargs else {'state': 'normal'}
        kwargs.pop('btn') if 'btn' in kwargs else None
        self.btn['state'] = tk.DISABLED

        LfpViewpoints.__init__(self, *args, **kwargs)
        kwargs.pop('cfg') if 'cfg' in kwargs else None
        kwargs.pop('sta') if 'sta' in kwargs else None

        tk.Canvas.__init__(self, *args, **kwargs)

        # take images from arguments or load from hard drive
        if 'vp_img_arr' in kwargs and 'refo_stack' in kwargs:
            self.vp_img_arr = kwargs['vp_img_arr']
            self.refo_stack = kwargs['refo_stack']
        else:
            self.load_data()

        # window settings
        self.master.title("PlenoptiCam Viewer")
        self.set_ascii_symbols()
        self.shape = self.vp_img_arr.shape[2:] if self.vp_img_arr is not None else (PY*30, PX*40, 1)
github hahnec / plenopticam / plenopticam / lfp_extractor / lfp_colors.py View on Github external
# external libs
import numpy as np

from plenopticam import misc
from plenopticam.misc import Normalizer
from plenopticam.lfp_extractor import LfpViewpoints

try:
    from scipy.signal import medfilt
    from scipy.ndimage import median_filter
except ImportError:
    raise ImportError('Please install scipy package.')

class LfpColors(LfpViewpoints):

    def __init__(self, *args, **kwargs):
        super(LfpColors, self).__init__(*args, **kwargs)

        self._gains = [1., 1., 1.]

    def main(self):

        # print status
        self.sta.status_msg('Automatic white balance', self.cfg.params[self.cfg.opt_prnt])
        self.sta.progress(None, self.cfg.params[self.cfg.opt_prnt])

        # estimate RGB gains based on central view using Huo's method
        self.robust_awb()

        # apply estimated gains to viewpoint array
github hahnec / plenopticam / plenopticam / lfp_extractor / lfp_color_eq.py View on Github external
import numpy as np

from plenopticam.lfp_extractor import LfpViewpoints
from plenopticam.lfp_aligner.cfa_processor import CfaProcessor
from plenopticam import misc

try:
    from scipy.signal import medfilt
    from scipy.ndimage import median_filter
except ImportError:
    raise ImportError('Please install scipy package.')

from color_matcher import ColorMatcher


class LfpColorEqualizer(LfpViewpoints):

    def __init__(self, *args, **kwargs):
        super(LfpColorEqualizer, self).__init__(*args, **kwargs)

        self._ref_img = kwargs['ref_img'] if 'ref_img' in kwargs else self.central_view
        self.prop_type = kwargs['prop_type'] if 'prop_type' in kwargs else 'central'
        self._method = 'mvgd'

    def main(self):

        # check interrupt status
        if self.sta.interrupt:
            return False

        # apply color correction
        if self.vp_img_arr is not None:
github hahnec / plenopticam / plenopticam / lfp_extractor / lfp_rearranger.py View on Github external
but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see .

"""

import numpy as np

from plenopticam.lfp_extractor import LfpViewpoints
from plenopticam.misc import PlenopticamError


class LfpRearranger(LfpViewpoints):

    def __init__(self, lfp_img_align=None, *args, **kwargs):
        super(LfpRearranger, self).__init__(*args, **kwargs)

        self._lfp_img_align = lfp_img_align if lfp_img_align is not None else None
        self._dtype = self._lfp_img_align.dtype if self._lfp_img_align is not None else self._vp_img_arr.dtype

    def _init_vp_img_arr(self):
        """ initialize viewpoint output image array """

        if len(self._lfp_img_align.shape) == 3:
            m, n, p = self._lfp_img_align.shape
        elif len(self._lfp_img_align.shape) == 2:
            m, n, p = self._lfp_img_align.shape[:2] + (1,)
        else:
            raise PlenopticamError('Dimensions %s of provided light-field not supported', self._lfp_img_align.shape,
github hahnec / plenopticam / plenopticam / lfp_extractor / lfp_contrast.py View on Github external
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see .

"""

import numpy as np

from plenopticam import misc
from plenopticam.lfp_extractor import LfpViewpoints
from color_space_converter import hsv_conv, yuv_conv, rgb2gry


class LfpContrast(LfpViewpoints):

    def __init__(self, p_lo=None, p_hi=None, *args, **kwargs):
        super(LfpContrast, self).__init__(*args, **kwargs)

        self.p_lo = p_lo if p_lo is not None else 0.0
        self.p_hi = p_hi if p_hi is not None else 1.0

        self.ref_img = kwargs['ref_img'] if 'ref_img' in kwargs else self.central_view

        # internal variables
        self._contrast, self._brightness = (1., 1.)

    def main(self):

        # check interrupt status
        if self.sta.interrupt:
github hahnec / plenopticam / plenopticam / lfp_extractor / lfp_outliers.py View on Github external
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see .

"""

from plenopticam.lfp_extractor import LfpViewpoints
from color_space_converter import yuv_conv

from scipy.signal import medfilt
import numpy as np


class LfpOutliers(LfpViewpoints):

    def __init__(self, *args, **kwargs):
        super(LfpOutliers, self).__init__(*args, **kwargs)

    def main(self):

        # check interrupt status
        if self.sta.interrupt:
            return False

        # remove outliers
        self.proc_vp_arr(self.correct_outliers, msg='Pixel outlier removal')

    def correct_outliers(self, img, n=2, perc=.2):

        for j in range(n, img.shape[0]-n):
github hahnec / plenopticam / plenopticam / gui / widget_view.py View on Github external
import tkinter as tk
except ImportError:
    import Tkinter as tk

from PIL import Image, ImageTk, ImageFont, ImageDraw
import os, sys
from functools import partial
import glob

from plenopticam.lfp_extractor import LfpViewpoints
from plenopticam.misc.os_ops import get_img_list
from plenopticam import __version__
from plenopticam.gui.constants import PX, PY


class ViewWidget(tk.Canvas, LfpViewpoints):

    def __init__(self, *args, **kwargs):

        # use button status for enabling/disabling purposes
        self.btn = kwargs['btn'] if 'btn' in kwargs else {'state': 'normal'}
        kwargs.pop('btn') if 'btn' in kwargs else None
        self.btn['state'] = tk.DISABLED

        LfpViewpoints.__init__(self, *args, **kwargs)
        kwargs.pop('cfg') if 'cfg' in kwargs else None
        kwargs.pop('sta') if 'sta' in kwargs else None

        tk.Canvas.__init__(self, *args, **kwargs)

        # take images from arguments or load from hard drive
        if 'vp_img_arr' in kwargs and 'refo_stack' in kwargs:
github hahnec / plenopticam / plenopticam / lfp_extractor / hex_corrector.py View on Github external
You should have received a copy of the GNU General Public License
    along with this program.  If not, see .

"""

import numpy as np
import os
from scipy.interpolate import interp1d

from plenopticam import misc
from plenopticam.lfp_extractor import LfpViewpoints
from plenopticam.lfp_aligner.lfp_resampler import LfpResampler


class HexCorrector(LfpViewpoints):

    def __init__(self, *args, **kwargs):
        super(HexCorrector, self).__init__(*args, **kwargs)

        self.ref_img = kwargs['ref_img'] if 'ref_img' in kwargs else self.central_view
        self.method = kwargs['method'] if 'method' in kwargs else 'cubic'

        if self.cfg.calibs[self.cfg.mic_list] is not None:
            # analyse
            self.hex_odd = LfpResampler.get_hex_direction(np.asarray(self.cfg.calibs[self.cfg.mic_list]))
        else:
            # reset pattern type to skip hex correction process
            self.cfg.calibs[self.cfg.pat_type] = 'rec'

    def main(self):
github hahnec / plenopticam / plenopticam / gui / ple_viewer.py View on Github external
# append to image list
            img_list.append((i, img))

    # sort image list by indices in file names
    img_tuples = sorted(img_list, key=lambda k: idx_str_sort(k[0], 1 if vp else 0))
    _, img_list = zip(*img_tuples)

    if vp:
        vp_dim = int(np.sqrt(len(img_list)))
        img_list = np.reshape(img_list, newshape=(vp_dim, vp_dim) + img_list[0].shape, order='C')

    return img_list


class PictureWindow(tk.Canvas, LfpViewpoints):
    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")