{"id":18366256,"url":"https://github.com/pydicom/pylibjpeg-rle","last_synced_at":"2025-04-06T16:32:03.020Z","repository":{"id":44843857,"uuid":"248103002","full_name":"pydicom/pylibjpeg-rle","owner":"pydicom","description":"Fast DICOM RLE plugin for pylibjpeg","archived":false,"fork":false,"pushed_at":"2024-12-01T21:06:46.000Z","size":128,"stargazers_count":6,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-18T22:46:15.768Z","etag":null,"topics":["decoder","dicom","encoder","packbits","pydicom","pylibjpeg","python","rle","rle-decoder","rle-encoder","rust"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pydicom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-18T00:35:37.000Z","updated_at":"2024-12-01T21:06:44.000Z","dependencies_parsed_at":"2024-02-02T00:07:19.133Z","dependency_job_id":null,"html_url":"https://github.com/pydicom/pylibjpeg-rle","commit_stats":{"total_commits":55,"total_committers":1,"mean_commits":55.0,"dds":0.0,"last_synced_commit":"cd288a4e590a71f8a4a6972d9f0defe794eaba65"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pydicom%2Fpylibjpeg-rle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pydicom%2Fpylibjpeg-rle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pydicom%2Fpylibjpeg-rle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pydicom%2Fpylibjpeg-rle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pydicom","download_url":"https://codeload.github.com/pydicom/pylibjpeg-rle/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247512842,"owners_count":20950942,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["decoder","dicom","encoder","packbits","pydicom","pylibjpeg","python","rle","rle-decoder","rle-encoder","rust"],"created_at":"2024-11-05T23:16:55.688Z","updated_at":"2025-04-06T16:32:02.724Z","avatar_url":"https://github.com/pydicom.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/pydicom/pylibjpeg-rle/actions?query=workflow%3Aunit-tests\"\u003e\u003cimg alt=\"Build status\" src=\"https://github.com/pydicom/pylibjpeg-rle/workflows/unit-tests/badge.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://codecov.io/gh/pydicom/pylibjpeg-rle\"\u003e\u003cimg alt=\"Test coverage\" src=\"https://codecov.io/gh/pydicom/pylibjpeg-rle/branch/main/graph/badge.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://pypi.org/project/pylibjpeg-rle/\"\u003e\u003cimg alt=\"PyPI versions\" src=\"https://img.shields.io/pypi/v/pylibjpeg-rle\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.python.org/\"\u003e\u003cimg alt=\"Python versions\" src=\"https://img.shields.io/pypi/pyversions/pylibjpeg-rle.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/psf/black\"\u003e\u003cimg alt=\"Code style: black\" src=\"https://img.shields.io/badge/code%20style-black-000000.svg\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## pylibjpeg-rle\n\nA fast DICOM ([PackBits](https://en.wikipedia.org/wiki/PackBits)) RLE plugin for [pylibjpeg](https://github.com/pydicom/pylibjpeg), written in Rust with a Python 3.7+ wrapper.\n\nLinux, MacOS and Windows are all supported.\n\n### Installation\n#### Installing the current release\n```bash\npip install pylibjpeg-rle\n```\n#### Installing the development version\n\nMake sure [Python](https://www.python.org/), [Git](https://git-scm.com/) and\n[Rust](https://www.rust-lang.org/) are installed. For Windows, you also need to install\n[Microsoft's C++ Build Tools](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools\u0026rel=16).\n```bash\ngit clone https://github.com/pydicom/pylibjpeg-rle\ncd pylibjpeg-rle\npython -m pip install .\n```\n\n### Supported Transfer Syntaxes\n\n| UID                 | Description  | Decoding | Encoding |\n| ---                 | ---          | ---      | ---      |\n| 1.2.840.10008.1.2.5 | RLE Lossless | Yes      | Yes      |\n\n### Usage\n#### Decoding\n##### With pylibjpeg\n\n```python\nfrom pydicom import dcmread\nfrom pydicom.data import get_testdata_file\n\nds = dcmread(get_testdata_file(\"OBXXXX1A_rle.dcm\"))\narr = ds.pixel_array\n```\n\n##### Standalone with pydicom\nAlternatively you can use the included functions to decode a given dataset:\n```python\nfrom rle import pixel_array, generate_frames\n\n# Return the entire Pixel Data as an ndarray\narr = pixel_array(ds)\n\n# Generator function that only processes 1 frame at a time,\n# may help reduce memory usage when dealing with large Pixel Data\nfor arr in generate_frames(ds):\n    print(arr.shape)\n```\n\n#### Encoding\n##### Standalone with pydicom\n\nConvert uncompressed pixel data to RLE encoding and save:\n```python\nfrom pydicom import dcmread\nfrom pydicom.data import get_testdata_file\nfrom pydicom.uid import RLELossless\n\nfrom rle import pixel_data\n\n# Get the uncompressed pixel data\nds = dcmread(get_testdata_file(\"OBXXXX1A.dcm\"))\narr = ds.pixel_array\n\n# RLE encode and encapsulate `arr`\nds.PixelData = pixel_data(arr, ds)\n# Set the correct *Transfer Syntax UID*\nds.file_meta.TransferSyntaxUID = RLELossless\nds.save_as('as_rle.dcm')\n```\n\n### Benchmarks\n#### Decoding\n\nTime per 1000 decodes, pydicom's default RLE handler vs. pylibjpeg-rle\n\n| Dataset                     | Pixels  | Bytes   | pydicom | pylibjpeg-rle |\n| ---                         | ---     | ---     | ---     | ---           |\n| OBXXXX1A_rle.dcm            | 480,000 | 480,000 | 4.89 s  |        0.79 s |\n| OBXXXX1A_rle_2frame.dcm     | 960,000 | 960,000 | 9.89 s  |        1.65 s |\n| SC_rgb_rle.dcm              |  10,000 |  30,000 | 0.20 s  |        0.15 s |\n| SC_rgb_rle_2frame.dcm       |  20,000 |  60,000 | 0.32 s  |        0.18 s |\n| MR_small_RLE.dcm            |   4,096 |   8,192 | 0.35 s  |        0.13 s |\n| emri_small_RLE.dcm          |  40,960 |  81,920 | 1.13 s  |        0.28 s |\n| SC_rgb_rle_16bit.dcm        |  10,000 |  60,000 | 0.33 s  |        0.17 s |\n| SC_rgb_rle_16bit_2frame.dcm |  20,000 | 120,000 | 0.56 s  |        0.21 s |\n| rtdose_rle_1frame.dcm       |     100 |     400 | 0.12 s  |        0.13 s |\n| rtdose_rle.dcm              |   1,500 |   6,000 | 0.53 s  |        0.26 s |\n| SC_rgb_rle_32bit.dcm        |  10,000 | 120,000 | 0.56 s  |        0.19 s |\n| SC_rgb_rle_32bit_2frame.dcm |  20,000 | 240,000 | 1.03 s  |        0.28 s |\n\n#### Encoding\n\nTime per 1000 encodes, pydicom's default RLE handler vs. pylibjpeg-rle\n\n| Dataset            | Pixels  | Bytes   | pydicom | pylibjpeg-rle |\n| ---                | ---     | ---     | ---     | ---           |\n| OBXXXX1A.dcm       | 480,000 | 480,000 | 30.7 s  |       1.36 s  |\n| SC_rgb.dcm         |  10,000 |  30,000 | 1.80 s  |       0.09 s  |\n| MR_small.dcm       |   4,096 |   8,192 | 2.29 s  |       0.04 s  |\n| SC_rgb_16bit.dcm   |  10,000 |  60,000 | 3.57 s  |       0.17 s  |\n| rtdose_1frame.dcm  |     100 |     400 | 0.19 s  |       0.003 s |\n| SC_rgb_32bit.dcm   |  10,000 | 120,000 | 7.20 s  |       0.33 s  |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpydicom%2Fpylibjpeg-rle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpydicom%2Fpylibjpeg-rle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpydicom%2Fpylibjpeg-rle/lists"}