getPixelData
Description
Examples
Get Pixel Data of DICOM File
Import a DICOM file into the workspace. The DICOM file is part of a data set containing three CT volumes. The size of the entire data set is approximately 81 MB. Download the data set from the MathWorks® website, then unzip the folder.
zipFile = matlab.internal.examples.downloadSupportFile("medical","MedicalVolumeDICOMData.zip"); filepath = fileparts(zipFile); unzip(zipFile,filepath) datapath = fullfile(filepath,"MedicalVolumeDICOMData/LungCT01/CT000000.dcm"); dFile = dicomFile(datapath);
Get the raw pixel data of the DICOM file.
rawPixelData = getPixelData(dFile,Rescale=false);
Visualize the raw pixel data.
figure imshow(rawPixelData,[])
Get the rescaled pixel data of the DICOM file.
rescaledPixelData = getPixelData(dFile);
Visualize the rescaled pixel data.
figure imshow(rescaledPixelData,[])
Observe that rescaling changes the range of the pixel data.
[min(rawPixelData,[],"all") max(rawPixelData,[],"all")]
ans = 1×2 int16 row vector
-2000 2520
[min(rescaledPixelData,[],"all") max(rescaledPixelData,[],"all")]
ans = 1×2 int16 row vector
-3024 1496
Input Arguments
dFile
— DICOM file
dicomFile
object
DICOM file from which to retrieve the pixel data, specified as a dicomFile
object.
rescale
— Rescale pixel data
true
or 1
(default) | false
or 0
Rescale pixel data, specified as a logical 1
(true
) or 0
(false
). If
rescale
is true
, the
getPixelData
function rescales the pixel data using the
rescaleSlope
and rescaleIntercept
attributes of
the DICOM file. Rescaling linearly transforms the on-disk representation of the pixel
data to its in-memory representation. For example, for CT images, rescaling transforms
the on-disk representation of intensity values to the standard Hounsfield units in the
in-memory representation. If the rescaleSlope
and
rescaleIntercept
attributes are not present in the DICOM file or if
you specify this argument as false
, the function returns the raw
pixel data. You can choose to get the raw pixel data if you want to modify the pixel
data and write it to a new DICOM file, to prevent repeated rescaling when reading pixel
data from the new DICOM file.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| logical
Output Arguments
pixelData
— Pixel data of DICOM file
2-D numeric matrix | 3-D numeric array
Pixel data of the DICOM file, returned as a 2-D numeric matrix or 3-D numeric array.
Version History
Introduced in R2023a
See Also
dicomFile
| isAttribute
| getAttribute
| findAttribute
| updateAttribute
| write
| dicomread
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)