LEADTOOLS Support
Medical
Medical SDK Questions
Convertion: JPG TO DICOM, DICOM Still capture
This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Thursday, May 18, 2006 1:23:36 AM(UTC)
Groups: Registered
Posts: 2
Hi,
I've three questions. I contacted the support for other questions, they were helpful, so I guess this time I would put it here.
1. How do you convert a jpg/tif file to dicom format (.dcm/.dic)
If you choose the source as a jpg file, the convert control errors out. but it has no problem with .avi file input.
Also, the capture control, the still capture mode does not have a dicom capture option but in bmp /jpg etc.
2. How do you still capture in dicom format.
3. How do you know, a .dcm or a .dic file is a clip or a still. (provided the file contents are ok.)
Thank you
#2
Posted
:
Thursday, May 18, 2006 12:57:49 PM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
If you want to create a proper DICOM file, you should use the LEADTOOLS DICOM engine (API, Class lib, VCL or COM) depending on your choice of compiler. The conversion using multimedia or raster engine will not create a valid DICOM unless you are using Direct Show DICOM Writer filter.
You need to do following to insert an image or image list that is loaded into LEADTOOLS raster object into a new DICOM file:
- Initialize the DICOM dataset by calling InitDS or loading a existing template dataset.
- Use FindFirstElement method to locate Pixel Data element to inset the image under.
- Copy the bitmap or bitmap list from raster object to ILEADDicomDS object. You can do this by assigning ILEADDicomDS’s Bitmap or BitmapList property the bitmap or bitmap list of ILEADRaster object.
LEADDICOM1.Bitmap = LEADRasterView1.Raster.Bitmap
LEADDICOM1.BitmapList= LEADRasterView1.Raster.BitmapList
- Call SetBitmapValue or SetBitmapListValue to insert the bitmap(s) into the DICOM dataset.
- Free the Bitmap or BitmapList by setting it to 0.
- You can now populate all the required DICOM tags (Type 1) following the IOD class requirement of DICOM standard for the modality type.
- You should remove all the optional empty elements from the dataset.
- Please make sure insert unique UIDs for Study, Series and Instances.
- Now you can save the file as DICOM with SaveDS call.
To get the information about how many frames in a DICOM file, you can call GetBitmapCount or GetImageInformation method of ILEADDicomDS. Please note that you have to the dataset loaded into ILEADDicomDS object.
Here is a sample of how to insert an image and create DICOM in VB:
LEADDICOM1.EnableMethodErrors = False
'move to the root element
LEADDICOM1.MoveFirstElement False
LEADDICOM1.MoveRootElement
'insert a new element for the Bitmap Value
nRet = LEADDICOM1.FindFirstElement (TAG_PIXEL_DATA, TURE)
nRet = LEADDICOM1.DeleteElement()
nRet = LEADDICOM1.InsertElement (False, TAG_PIXEL_DATA, VR_OW, False, 0)
'load an image
IO.Load LEADRasterView1.Raster, "d:\lead14\dist\images\image1.cmp", 0, 1, 1
'insert the image into the element
LEADDICOM1.Bitmap = LEADRasterView1.Raster.Bitmap
#3
Posted
:
Thursday, November 9, 2006 11:15:45 PM(UTC)
Groups: Registered
Posts: 4
I tried this example (in conjunction with some examples from the help file) to create a simple converter for jpeg files. This is the C# code:
LEADDicomDSClass ds = new LEADDicomDSClass();
LEADRasterIOClass IO = new LEADRasterIOClass();
LEADRasterView view = new LEADRasterView();
ds.InitDS((int)LTDICLib.DicomClassConstants.DICOM_CLASS_CR_IMAGE_STORAGE, (
short)LTDICLib.DicomDataSetFlags.DS_EXPLICIT_VR +
(short)LTDICLib.DicomDataSetFlags.DS_METAHEADER_ABSENT +
(short)LTDICLib.DicomDataSetFlags.DS_BIG_ENDIAN);
ds.EnableMethodErrors = false;
//move to the root element
ds.MoveFirstElement(false);
ds.MoveRootElement();
ds.FindFirstElement((int)DicomDataSetTagConstants9.TAG_PIXEL_DATA, true);
ds.DeleteElement();
ds.InsertElement(false, (int)DicomDataSetTagConstants9.TAG_PIXEL_DATA, (short)LTDICLib.DicomVRCodeConstants.VR_OB, false, 0);
IO.Load(view.Raster, "E:\\workspace\\132_22.jpg", 0, 1, 1);
ds.Bitmap = view.Raster.Bitmap;
ds.SetBitmapValue((int)DicomImageCompressionConstants.DICOM_IMAGE_COMPRESSION_NONE,
(int)DicomImagePhotometricConstants.DICOM_IMAGE_PHOTOMETRIC_MONOCHROME1, 0, 0, 0);
ds.SaveDS("E:\\tmp.dcm",0);
Unfortunately, I get some errors on executing, which say that I use an
invalid bitmap handle ("LEAD Error: Invalid bitmap handle"), so I fear
I have some problems loading the image... any ideas?
#4
Posted
:
Sunday, November 12, 2006 12:22:22 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
This error indicates that the bitmap you are trying to process is empry. On which line do you get this error?
#5
Posted
:
Sunday, November 12, 2006 9:28:29 PM(UTC)
Groups: Registered
Posts: 4
ds.SetBitmapValue((int)DicomImageCompressionConstants.DICOM_IMAGE_COMPRESSION_NONE,
(int)DicomImagePhotometricConstants.DICOM_IMAGE_PHOTOMETRIC_MONOCHROME1, 0, 0, 0);
So it's after I hand over the bitmap handle from my raster view to the ds. The Bitmap-File itself works, I tried it with your AxLEADRasterView example which I found in another thread. I'm creating a console application, so I cannot use the Active X Controls, I fear.
#6
Posted
:
Monday, November 13, 2006 5:16:20 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
I put your code fragment in a project and it worked. Please post
the project you are testing with so that I can try it over here.
#7
Posted
:
Wednesday, November 15, 2006 9:25:41 PM(UTC)
Groups: Registered
Posts: 4
#8
Posted
:
Thursday, November 16, 2006 2:57:44 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
Are you using the trial or full version of LEADTOOLS? If you are
using the full version, then you have to call UnlockSupport to unlock
the Medical features. Your project didn't work as is, but when I
added the call to UnlockSupport it worked.
#9
Posted
:
Thursday, November 16, 2006 3:14:57 AM(UTC)
Groups: Registered
Posts: 4
I'm using the full version of v14. Where do I find this method?
#10
Posted
:
Thursday, November 16, 2006 3:38:52 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
It's in LEADDicomKernelClass. Create an instance of this class
and call the method before calling an DICOM-related methods.
Also, the way you are creating the LEAD objects will cause you problems
when you deploy your application. Use the LEADRasterFactory
class's CreateObject method to create the LEAD objects.
LEADTOOLS Support
Medical
Medical SDK Questions
Convertion: JPG TO DICOM, DICOM Still capture
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.