how to extract frames from DICOM "Mpeg2 Main Profile @ Main Level" file
Moderator: Moderator Team
how to extract frames from DICOM "Mpeg2 Main Profile @ Main Level" file
Hello
I want to develope a programe using VS c++ and dcmtk that can load a dicom file which has the following caracterestics:
Mpeg2 Main Profile @ Main Level --> transfer syntax
YBR_PARTIAL_422 (0028,0004) --> photometric Interpretation
VedioEndoscopocImageStorage --> SOP class UID
I tried to load it use the DicomImage class or DcmFileFormat class but i get always the following error :
can't change to unencapsulated representation for pixel module
so please is it possible to load this type of files using dcmtk and how I can do that ?
I want to develope a programe using VS c++ and dcmtk that can load a dicom file which has the following caracterestics:
Mpeg2 Main Profile @ Main Level --> transfer syntax
YBR_PARTIAL_422 (0028,0004) --> photometric Interpretation
VedioEndoscopocImageStorage --> SOP class UID
I tried to load it use the DicomImage class or DcmFileFormat class but i get always the following error :
can't change to unencapsulated representation for pixel module
so please is it possible to load this type of files using dcmtk and how I can do that ?
-
- DCMTK Developer
- Posts: 2054
- Joined: Fri, 2004-11-05, 13:47
- Location: Oldenburg, Germany
- Contact:
Hi,
the problem with DicomImage class is that DCMTK is not able to decode MPEG2 data in order to access its frames or the "images" included at all. So forget about using DicomImage.
However, loading with DcmFileformat should work. After that you may access the raw MPEG2 data by further API calls, e.g. to visualize it using ffmpeg or any other library/program. Where is DcmFileformat exactly failing?
Best regards,
Michael
the problem with DicomImage class is that DCMTK is not able to decode MPEG2 data in order to access its frames or the "images" included at all. So forget about using DicomImage.
However, loading with DcmFileformat should work. After that you may access the raw MPEG2 data by further API calls, e.g. to visualize it using ffmpeg or any other library/program. Where is DcmFileformat exactly failing?
Best regards,
Michael
thank you very much for your answer
In fact with DcmFileFormat I have no loading errors but if I use this Class how I can extract certain frames from the vedio included in this file?
or there is another Class that enables me to do that ??
to be more clear: I want to extarct certain frames numbers(i.e 1,20,56,70) and save them as jpeg images that's why I tried to use DicomImage since it enables me to get the frames that I want.
thank you for you help
regards
In fact with DcmFileFormat I have no loading errors but if I use this Class how I can extract certain frames from the vedio included in this file?
or there is another Class that enables me to do that ??
to be more clear: I want to extarct certain frames numbers(i.e 1,20,56,70) and save them as jpeg images that's why I tried to use DicomImage since it enables me to get the frames that I want.
thank you for you help
regards
-
- ICSMED DICOM Services
- Posts: 2217
- Joined: Fri, 2004-10-29, 21:38
- Location: Oldenburg, Germany
Hi,
Load the image using the DcmFileFormat class and
use the following function to extract pixel data in unsigned 8-bit integers format:
There are different similar functions for accessing pixel data in signed and unsgined 16 and 32 bit format:
HTH,
Alvin
Load the image using the DcmFileFormat class and
use the following function to extract pixel data in unsigned 8-bit integers format:
Code: Select all
findAndGetUint8Array(...)
Code: Select all
findAndGetUint16Array
findAndGetSint16Array
findAndGetUint32Array
findAndGetSint32Array
Alvin
thank you very much for your helpful reply
but I have problem here
I got always "zero" for the count ;
result count = 0
so could you please tell me what is the problem and what I have to do to solve il to be able to extract the needed frames??
best regards
but I have problem here
Code: Select all
unsigned long count = 0;
const Uint8 *myPixelData= NULL;
cond = dataset->findAndGetUint8Array(DCM_PixelData, myPixelData,&count);
if(cond.bad())
{
cout<<"error get pixel data "<<cond.text()<<endl;
}
else
cout<<"result count = " << count << endl;
result count = 0
so could you please tell me what is the problem and what I have to do to solve il to be able to extract the needed frames??
best regards
-
- DCMTK Developer
- Posts: 2054
- Joined: Fri, 2004-11-05, 13:47
- Location: Oldenburg, Germany
- Contact:
Hi,
@alwitta: Thanks for helping out! However, that only works for uncompressed pixel data.
For compressed pixel data you have to use the DcmPixelSequence class due to the internal structure of the compressed PixelData element. This gives you acccess to the included offset table (empty for MPEG2) and all frames. However, for MPEG2 there is only a single "frame" containing all MPEG2 data as a blob . You won't be able to access individual frames with DCMTK because DCMTK does not know how to decompress MPEG2 data and hence is not able to find out where a specific frame begins.
So you have to get the complete MPEG2 data, and then decompress it using another library. I will post an example how to do that soon in the wiki and reference here in the forum topic.
Best regards,
Michael
@alwitta: Thanks for helping out! However, that only works for uncompressed pixel data.
For compressed pixel data you have to use the DcmPixelSequence class due to the internal structure of the compressed PixelData element. This gives you acccess to the included offset table (empty for MPEG2) and all frames. However, for MPEG2 there is only a single "frame" containing all MPEG2 data as a blob . You won't be able to access individual frames with DCMTK because DCMTK does not know how to decompress MPEG2 data and hence is not able to find out where a specific frame begins.
So you have to get the complete MPEG2 data, and then decompress it using another library. I will post an example how to do that soon in the wiki and reference here in the forum topic.
Best regards,
Michael
Hi,
@Ro2a: Sorry for the wrong reply.
@Michael: Thanks for the information.
Meanwhile, in the dcmdump program there is an option to extract the pixel data to file using the +W option.
Thanks and Regards,
Alvin
@Ro2a: Sorry for the wrong reply.
@Michael: Thanks for the information.
Meanwhile, in the dcmdump program there is an option to extract the pixel data to file using the +W option.
Code: Select all
dcmdump.exe -d +W d:\output 1.dcm
Alvin
-
- DCMTK Developer
- Posts: 2054
- Joined: Fri, 2004-11-05, 13:47
- Location: Oldenburg, Germany
- Contact:
Hi,
here is an howto describing how to access compressed image data with DCMTK.
Hope that helps,
Michael
here is an howto describing how to access compressed image data with DCMTK.
Hope that helps,
Michael
thank you very much for this very interesting way of decompresing the image data using DCMTK
So according to you in all the cases I will not be able to extract certain frames from the MPEG2 DICOM image even if I decompress the data, that's right ??
so I have to use another library in addition to DCMTK in order to achive the extraction of certain frames ???
thank you again for your great help
regards
So according to you in all the cases I will not be able to extract certain frames from the MPEG2 DICOM image even if I decompress the data, that's right ??
so I have to use another library in addition to DCMTK in order to achive the extraction of certain frames ???
thank you again for your great help
regards
-
- ICSMED DICOM Services
- Posts: 2217
- Joined: Fri, 2004-10-29, 21:38
- Location: Oldenburg, Germany
Of course, if you decompress the MPEG2 stream you would be able to extract certain frames However, this requires some additional library like "ffmpeg".
Btw, we haven't yet added support for compressing and decompressing MPEG2 to the DCMTK mainly because of licensing issues (and because of limited time, of course).
Btw, we haven't yet added support for compressing and decompressing MPEG2 to the DCMTK mainly because of licensing issues (and because of limited time, of course).
-
- DCMTK Developer
- Posts: 2054
- Joined: Fri, 2004-11-05, 13:47
- Location: Oldenburg, Germany
- Contact:
thank you and sorry for asking a lot of question but I need you help to tell me at which step I have to decompress the image in order to use within the dcmtk library?
do I decompress it (by using ffmpeg for example) and the I load the image by using fileformat? or after decompressing the MPEG I can load it by using the dicomImage Class ??
regards
do I decompress it (by using ffmpeg for example) and the I load the image by using fileformat? or after decompressing the MPEG I can load it by using the dicomImage Class ??
regards
Who is online
Users browsing this forum: Semrush [Bot] and 1 guest