示例#1
0
    def __init__(self, ids, early_config, metrics_config, name):
        try:
            config_lp = None
            library = pressio.instance()
            metrics_ids = pressio.vector_string([i.encode() for i in ids])
            self._metric = pressio.new_metrics(library, metrics_ids)
            self._metric_id = "composite"
            if not self._metric:
                raise PressioException.from_library(library)

            if name is not None:
                pressio.metrics_set_name(self._metric, name.encode())

            early_config_lp = _python_to_pressio(early_config)
            pressio.metrics_set_options(self._metric, early_config_lp)
            pressio.options_free(early_config_lp)

            config_lp_template = pressio.metrics_get_options(self._metric)
            config_lp = _python_to_pressio(metrics_config, config_lp_template)

            pressio.metrics_set_options(self._metric, config_lp)
        finally:
            pressio.release(library)
            pressio.options_free(config_lp)
            pressio.options_free(config_lp_template)
示例#2
0
    def __init__(self, compressor_id, early_config, compressor_config, name):
        """wrapper for a libpressio compressor object

        params:
            compressor_id: str - the compressor_id for the underlying compressor
            early_config: dict - converted to pressio_options to configure the structure of the compressor
            compressor_config: dict - converted to pressio_options to configure the compressor
            name: str - name to use for the compressor when used in a hierarchical mode
        """
        try:
            library = pressio.instance()
            self._compressor = pressio.get_compressor(library,
                                                      compressor_id.encode())
            if self._compressor is None:
                raise PressioException.from_library(library)

            if name is not None:
                pressio.compressor_set_name(self._compressor, name.encode())

            early_config_lp = _python_to_pressio(early_config)
            pressio.compressor_set_options(self._compressor, early_config_lp)
            pressio.options_free(early_config_lp)

            config_lp = pressio.compressor_get_options(self._compressor)
            config_lp = _python_to_pressio(compressor_config, config_lp)

            pressio.compressor_set_options(self._compressor, config_lp)
            pressio.options_free(config_lp)
        finally:
            pressio.release(library)
示例#3
0
    def __init__(self, io, early_config, io_config, name):
        try:
            config_lp = None
            library = pressio.instance()
            self._io = pressio.get_io(library, io.encode())
            if not self._io:
                raise PressioException.from_library(library)

            if name is not None:
                pressio.compressor_set_name(self._io, name.encode())

            early_config_lp = _python_to_pressio(early_config)
            pressio.io_set_options(self._io, early_config_lp)
            pressio.options_free(early_config_lp)

            config_lp = pressio.io_get_options(self._io)
            config_lp = _python_to_pressio(io_config, config_lp)

            pressio.io_set_options(self._io, config_lp)
        finally:
            pressio.release(library)
            pressio.options_free(config_lp)
示例#4
0
    #open image get path from array
    im = Image.open(imgs, 'r')
    #DO I CARE ABOUT THIS ANYMORE?
    OutputID = re.findall("(\d+)", imgs)

    #load images
    pix_vals = im.load()
    width, height = im.size

    #Create Datasets From Image For extrapolation
    intArray = []
    intArray = createIntArray(pix_vals, width, height)
    floatArray = createFloatArray(intArray, width, height)

    library = pressio.instance()
    compressor = pressio.get_compressor(library, b"sz")
    sz_options = pressio.compressor_get_options(compressor)
    metric_ids = pressio.vector_string([b'time', b'size'])
    metrics = pressio.new_metrics(library, metric_ids)

    pressio.options_set_integer(sz_options, b"sz:error_bound_mode", sz.PSNR)
    pressio.options_set_double(sz_options, b"sz:psnr_err_bound",
                               float(sys.argv[1]))

    pressio.compressor_check_options(compressor, sz_options)
    pressio.compressor_set_options(compressor, sz_options)
    pressio.compressor_set_metrics(compressor, metrics)

    input_data = pressio.io_data_from_numpy(floatArray)