A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pydicom/pylibjpeg-openjpeg below:

pydicom/pylibjpeg-openjpeg: A J2K, JP2 and HTJ2K plugin for pylibjpeg

A Python 3.8+ wrapper for openjpeg, with a focus on use as a plugin for pylibjpeg.

Linux, OSX and Windows are all supported.

NumPy

Installing the current release
python -m pip install -U pylibjpeg-openjpeg
Installing the development version

Make sure Python, Git and CMake are installed. For Windows, you also need to install Microsoft's C++ Build Tools.

git clone --recurse-submodules https://github.com/pydicom/pylibjpeg-openjpeg
python -m pip install pylibjpeg-openjpeg

Encoding of NumPy ndarrays is supported for the following:

UID Description 1.2.840.10008.1.2.4.90 JPEG 2000 Image Compression (Lossless Only) 1.2.840.10008.1.2.4.91 JPEG 2000 Image Compression 1.2.840.10008.1.2.4.201 High-Throughput JPEG 2000 Image Compression (Lossless Only) 1.2.840.10008.1.2.4.202 High-Throughput JPEG 2000 with RPCL Options Image Compression (Lossless Only) 1.2.840.10008.1.2.4.203 High-Throughput JPEG 2000 Image Compression With pylibjpeg and pydicom
from pydicom import dcmread
from pydicom.data import get_testdata_file

ds = dcmread(get_testdata_file('JPEG2000.dcm'))
arr = ds.pixel_array

You can also decode JPEG 2000 images to a numpy ndarray:

from openjpeg import decode

with open('filename.j2k', 'rb') as f:
    # Returns a numpy array
    arr = decode(f)

# Or simply...
arr = decode('filename.j2k')

Lossless encoding of RGB with multiple-component transformation:

import numpy as np
from openjpeg import encode_array

arr = np.random.randint(low=0, high=65536, size=(100, 100, 3), dtype="uint8")
encode_array(arr, photometric_interpretation=1)  # 1: sRGB

Lossy encoding of a monochrome image using compression ratios:

import numpy as np
from openjpeg import encode_array

arr = np.random.randint(low=-2**15, high=2**15, size=(100, 100), dtype="int8")
# You must determine your own values for `compression_ratios`
#   as these are for illustration purposes only
encode_array(arr, compression_ratios=[5, 2])

Lossy encoding of a monochrome image using peak signal-to-noise ratios:

import numpy as np
from openjpeg import encode_array

arr = np.random.randint(low=-2**15, high=2**15, size=(100, 100), dtype="int8")
# You must determine your own values for `signal_noise_ratios`
#   as these are for illustration purposes only
encode_array(arr, signal_noise_ratios=[50, 80, 100])

See the docstring for the encode_array() function for full details.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4