Main Content
Create Image Datastore Containing DICOM Images
This example shows how to create an image datastore from a collection of DICOM files containing 2-D images. To learn more about organizing images labeled using the Medical Image Labeler (Medical Imaging Toolbox) app, see Create Datastores for Medical Image Semantic Segmentation (Medical Imaging Toolbox).
Specify the location of a directory containing 2-D DICOM image files.
dicomDir = "dog";
Create an imageDatastore
object, specifying the read function as a handle to the dicomread
function.
dicomds = imageDatastore(dicomDir, ... FileExtensions=".dcm",ReadFcn=@(x) dicomread(x));
Read and display the first image in the datastore.
I = read(dicomds);
Display the image. The image has signed 16-bit data, so scale the display range to the pixel values in the image.
imshow(I,[])