How can I extract single frames from multi-frame DICOM file

1,546 views
Skip to first unread message

Leandro Marques

unread,
Nov 18, 2015, 1:35:58 PM11/18/15
to dcm4che
Hello,

How can I extract single frames from multi-frame DICOM file? I saw an example with dcm4che-tool-emf2sf but this functionality is limited to EnhancedCTImage, EnhancedMRImage and EnhancedPETImage. I need to apply this feature for all images types.

How can I proceed?

BR, Leandro.

Leandro Marques

unread,
Dec 9, 2015, 7:55:43 AM12/9/15
to dcm4che
After better understanding of problem I discovered that my scenario was a little different. In fact I needed to extract multiple images from tag Pixel Data (7FE0, 0010) with some offset. Through site Dicom Is Easy I understood how can I calculate the pixel data length for each image. The mathematical formula that I used was: ROWS * COLUMNS * NUMBER_OF_FRAMES * SAMPLES_PER_PIXEL * (BITS_ALLOCATED/8). More details can be seen at http://dicomiseasy.blogspot.com.br/2012/08/chapter-12-pixel-data.html. My code that I used was:

// Extract multiple images from tag pixel data
int rows = data.getInt(Tag.Rows, 1);
int columns = data.getInt(Tag.Columns, 1);
int samplePerPixel = data.getInt(Tag.SamplesPerPixel, 1);
int bitsAllocated = data.getInt(Tag.BitsAllocated, 8);
// frame size in number of bytes
int frameSize = rows * columns * samplePerPixel * bitsAllocated / 8;
// raw pixel data
byte[] raw = data.getBytes(Tag.PixelData);
int from = 0;
int to = frameSize;
for (int frame = 0; frame < raw.length/frameSize; frame++) {
      byte[] image = Arrays.copyOfRange(raw, from, to);
      data.remove(Tag.PixelData);
      data.setBytes(Tag.PixelData, VR.OW, image);
      saveDicomFile(editorFolder, imagesName.get(frame).replace(IMAGE_FORMAT, DICOM_FILE), data, transferSyntax);
      from += frameSize;
      to += frameSize;
}

Im my case this solution solved my problem.
Reply all
Reply to author
Forward
0 new messages