Extracting 2d array from numpy.pixel_array dicom image

In summary, the conversation discusses the process of separating and manipulating pixel data from a DICOM image using numpy. The array of shape [2, 1024, 1024] represents two images from each detector head on the scanner. The speaker mentions using numpy to "slice" the array, but finds the orientations confusing and unable to separate the images into their own arrays. Another speaker suggests a simpler solution of assigning the separate arrays to variables. The conversation ends with a comment about alternative approaches in other programming languages.
  • #1
ProPatto16
326
0
Hi guys,

I have a dicom image from a QC spect acquisition.
reading the file in with dicom.read_file and pulling pixel data using numpy.pixel_array gives array of shape [2, 1024, 1024]

The 2 represents two images, one from each detector head on the spect scanner and the 1024x1024 are the arrays i want to separate and pull out individually, i.e. so i can manipulate the pixel data, remove buffering 0's, plot histograms of the pixel values etc etc. i have artifacts in one detector head so i need to be able to separate the two slices

looking at numpy package there are ways to "slice" my array but the orientations are confusing and it doesn't separate them into their own arrays.

This should be quite elementary i would of thought

Thanks
 
Technology news on Phys.org
  • #2
so it looks like its this easy..

'array' is my array of shape [2,1024,1024]

to get the two 1024x1024 arrays out is simply

1stArray = array[0] and 2ndArray = array[1]
..
ill know for sure when i map them
 
  • #3
ProPatto16 said:
so it looks like its this easy..

'array' is my array of shape [2,1024,1024]

to get the two 1024x1024 arrays out is simply

1stArray = array[0] and 2ndArray = array[1]
..
Yes, it is correct though it doesn't look intuitive. :smile:
In C++, I would probably use i.e a tuple then tie its values to declared variables. Other than that I might use a struct of e.g 3 elements to store the returned values. You can do the same to make more sense of your current approach.
 

What is a 2D array?

A 2D array, or two-dimensional array, is a data structure that stores values in a grid-like format with rows and columns. It is commonly used to represent images, tables, and matrices in programming.

What is numpy.pixel_array in dicom images?

Numpy.pixel_array is a function in the NumPy library that allows for the conversion of DICOM images into a NumPy array. This array can then be manipulated and analyzed using various scientific computing tools.

How do you extract a 2D array from a numpy.pixel_array dicom image?

To extract a 2D array from a numpy.pixel_array dicom image, you can use the "pixel_array" attribute of the DICOM image object. This will return a NumPy array that represents the pixel values of the image.

What are some common applications of extracting 2D arrays from dicom images?

Extracting 2D arrays from dicom images is commonly used in medical imaging, as DICOM is the standard format for medical images. These arrays can then be used for image processing, analysis, and visualization.

What are the advantages of using numpy.pixel_array to extract 2D arrays from dicom images?

Using numpy.pixel_array allows for efficient and accurate extraction of 2D arrays from dicom images. It also enables easy integration with other scientific computing tools for further analysis and processing of the image data.

Similar threads

  • Programming and Computer Science
Replies
3
Views
3K
Replies
22
Views
6K
Replies
2
Views
897
  • Programming and Computer Science
Replies
4
Views
2K
  • Programming and Computer Science
Replies
10
Views
25K
  • Programming and Computer Science
Replies
1
Views
3K
Replies
13
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
5K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
4K
Back
Top