Mercurial > hg > orthanc-book
comparison Sphinx/source/plugins/python.rst @ 706:c62539d00251
Conversions between Orthanc and Python images
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 11 Jun 2021 12:42:39 +0200 |
parents | ba2403ebd4b7 |
children | daf07750e901 |
comparison
equal
deleted
inserted
replaced
705:745d93684b0b | 706:c62539d00251 |
---|---|
497 The following sample Python script will write on the disk a new DICOM | 497 The following sample Python script will write on the disk a new DICOM |
498 instance including the traditional Lena sample image, and will decode | 498 instance including the traditional Lena sample image, and will decode |
499 the single frame of this DICOM instance: | 499 the single frame of this DICOM instance: |
500 | 500 |
501 .. literalinclude:: python/create-dicom.py | 501 .. literalinclude:: python/create-dicom.py |
502 :language: python | |
503 | |
504 | |
505 .. _python_pil_conversions: | |
506 | |
507 Conversions between Orthanc and Python images (new in 3.2) | |
508 .......................................................... | |
509 | |
510 The Python method ``orthanc.Image.GetImageBuffer()`` returns a copy of | |
511 the memory buffer of an image that is handled Orthanc. Conversely, the | |
512 Python function ``orthanc.CreateImageFromBuffer()`` can be used to | |
513 create an Orthanc image from a Python buffer. Taken together, these | |
514 two functions can be used to do bidirectional conversions between | |
515 Orthanc images and Python images. | |
516 | |
517 Here is a full working example using PIL/Pillow that shows how to | |
518 decode a DICOM instance using Orthanc, then to modify this image using | |
519 PIL, and finally to upload the modified image as a new DICOM instance: | |
520 | |
521 .. literalinclude:: python/pil-conversions.py | |
502 :language: python | 522 :language: python |
503 | 523 |
504 | 524 |
505 .. _python_dicom_scp: | 525 .. _python_dicom_scp: |
506 | 526 |