LEADTOOLS Support
Medical
Medical SDK Questions
rouble creating a dcm file by reading the raw file.
#1
Posted
:
Friday, August 11, 2017 2:49:21 AM(UTC)
Groups: Registered
Posts: 1
I am developing using the C ++ class library v19.
The development environment is Qt 5.8.
I need to read the raw data file and create a dicom file.
Are there any C ++ examples related to this?
Https://www.leadtools.co...iththerawfilefilter.htmlI tried this example, but I get an invalid format error.
It is very good when you load a bmp file as a test.
#2
Posted
:
Friday, August 11, 2017 6:08:34 PM(UTC)
Groups: Tech Support
Posts: 366
Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
Hello,
When you say you need to read raw data, are you trying to load data from a headerless file or are you referring to just raw image data in memory? Each of these have different solutions.
I don't know of any specific examples to point you to regarding taking raw data and putting it in a DICOM file, but I will try to provide some guidance on how to go about doing it here.
With respect to inserting the image data into a DICOM file, you'll need the image data to be wrapped with our BITMAPHANDLE. This can then be passed to the LDicomDS::InsertImage() method to be put into a dataset. Then you can write the file out.
For a simple test, you could do the following:
1.) Load a BMP
2.) Load a template DICOM file with
LoadDS()3.) Insert the image data (from the BMP) into the dataset with
InsertImage()4.) Save the new DICOM file with
SaveDS()Here's a code snippet for illustration:
Code:
L_INT nRet;
LDicomDS* pDS;
pDICOMELEMENT pElement;
pDS = new LDicomDS(NULL);
nRet = pDS->LoadDS(L_TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\image1.dcm"), 0);
if(nRet != DICOM_SUCCESS)
return nRet;
pElement = pDS->FindFirstElement(NULL, TAG_PIXEL_DATA, FALSE);
if (pElement != NULL)
{
LBitmapBase BitmapBase;
BitmapBase.SetFileName(L_TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\cannon.jpg")));
BitmapBase.Load(0,ORDER_BGR, NULL);
pBITMAPHANDLE pBitmap = BitmapBase.GetHandle();
nRet = pDS->InsertImage(pElement, pBitmap, 1, IMAGE_COMPRESSION_NONE,
IMAGE_PHOTOMETRIC_MONOCHROME2, 0, 0, DICOM_SETIMAGE_AUTO_SET_VOI_LUT, NULL, NULL);
if(nRet != DICOM_SUCCESS)
return nRet;
}
nRet = pDS->SaveDS(L_TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\temp.dcm")), 0);
if(nRet != DICOM_SUCCESS)
return nRet;
delete pDS;
So as long as you can get a pointer to a bitmap to pass to InsertImage(), that should be all that you need. If you just have the raw data in memory, you could
create the bitmap handle without the image data first (memory type = TYPE_USER) , and then use
SetDataPointer() to provide your user data after the fact.
Walter Bates
Senior Support Engineer
LEAD Technologies, Inc.
LEADTOOLS Support
Medical
Medical SDK Questions
rouble creating a dcm file by reading the raw file.
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.