示例#1
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)
示例#2
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)

    compressed_data = pressio.data_new_empty(pressio.byte_dtype,