# how to create itk image from buffered dicom data

**URL:** https://discourse.itk.org/t/how-to-create-itk-image-from-buffered-dicom-data/4895
**Category:** Beginner Questions
**Created:** [March 31, 2022, 6:29pm UTC](https://discourse.itk.org/t/how-to-create-itk-image-from-buffered-dicom-data/4895 "2022-03-31T18:29:50Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![mmeltsner](https://discourse.itk.org/user_avatar/discourse.itk.org/mmeltsner/32/2637_2.png) [@mmeltsner](https://discourse.itk.org/u/mmeltsner)
#### Post date: [March 31, 2022, 6:29pm UTC](https://discourse.itk.org/t/how-to-create-itk-image-from-buffered-dicom-data/4895/1 "2022-03-31T18:29:50Z")

</div>

hello,  
i am currently able to nicely create itk images from dicom data by utilizing the gdcmimageio and the imagefilereader by reading a file from disk. However, i am writing an application in which the .dcm file is transmitted to me via binary data in a buffer over a network. Can anyone help me to figure out how to instead of forcing the imageio to read from disk to use the data already in memory? I couldn’t find a lot of clear answers on this anywhere and I don’t want to write the data from memory to disk and read it back in from disk as that is time consuming and not very elegant.  
thanks,

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [March 31, 2022, 6:46pm UTC](https://discourse.itk.org/t/how-to-create-itk-image-from-buffered-dicom-data/4895/2 "2022-03-31T18:46:08Z")

</div>

Take a look at this post:

> [@Reading/Writing Images to/from Memory (Rather than Files)](https://discourse.itk.org/t/reading-writing-images-to-from-memory-rather-than-files/3763/3):
>
> In 3D Slicer, we have a file-free ITK image IO plugin that we use to send/receive images in Slicer modules that are loaded as a dynamic library. You just register this plugin as any the other IO plugins. To pass an image to a module you don’t even need to write a file, just create a special filename (in our case it is slicer:\<scene\_memory\_address\>:\<volume\_node\_id\>) that the IO plugin recognizes and parses to get the memory address of the image. See source code of the IO plugin [here](https://github.com/Slicer/Slicer/tree/master/Libs/MRML/IDImageIO) and see how y…

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [March 31, 2022, 6:50pm UTC](https://discourse.itk.org/t/how-to-create-itk-image-from-buffered-dicom-data/4895/3 "2022-03-31T18:50:37Z")

</div>

I don’t think this will work for DICOM images. That is more of a question for [GDCM project](https://sourceforge.net/projects/gdcm/) or [DCMTK forum](https://forum.dcmtk.org/).

---

<div class="post-metadata">

### Author: ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)
#### Post date: [March 31, 2022, 7:00pm UTC](https://discourse.itk.org/t/how-to-create-itk-image-from-buffered-dicom-data/4895/4 "2022-03-31T19:00:06Z")

</div>

As ITK IO is file oriented, possibly consider a [RAM disk](https://en.wikipedia.org/wiki/RAM_drive). It’s not an elegant solution as it still requires write/read, but it may be fast enough.

---

<div class="post-metadata">

### Author: ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)
#### Post date: [June 28, 2022, 12:00am UTC](https://discourse.itk.org/t/how-to-create-itk-image-from-buffered-dicom-data/4895/5 "2022-06-28T00:00:08Z")

</div>

For future reference: Added some code to [this SimpleITK notebook](https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks/blob/master/Python/03_Image_Details.ipynb) illustrating this possible workaround in Python (setting up a RAM disk may not be critical if you have an NVMe drive).
