Hello everybody, I have a DICOM file include header and image. I want to replace the image in dicom file by other image (example testimage.jpg). So I will use DicomImage class to do it. But I don't know function to do it. How to replace Image in Dicom file?
My idea has two steps:
+ First step, I will delete image in the Dicom file
+ Second stem, I will add a new Image in DICOM file.
Is my idea correct or not correct?
How to replace Image in Dicom file
Moderator: Moderator Team
-
- Posts: 347
- Joined: Mon, 2009-02-23, 19:57
Re: How to replace Image in Dicom file
Instead of trying to replace the PixelData, you can create a new image, copy the original header, add the new pixeldata and save with the same filename as the original.
-
- Posts: 24
- Joined: Thu, 2013-01-10, 16:40
Re: How to replace Image in Dicom file
I think this idea not accurate. Because you can not copy all information in header and dataset in a new file. Instead of you must get pixel data from jpg file and copy it into PixelData Tag in DICOM file. But I try to copy but not successfully. The first I will convert image to dataset by code
The second I will get pixelData in dataset and using putAndInsertUint8Array in the dicomfile refference from http://support.dcmtk.org/wiki/dcmtk/how ... essed-data, after I can not open the dicom.
Code: Select all
Image2Dcm i2d;
I2DOutputPlug *outPlug = new I2DOutputPlugSC();
I2DImgSource *inputPlug = new I2DJpegSource();
E_TransferSyntax writeXfer;
inputPlug->setImageFile("abc.jpg");
DcmDataset *dataset = NULL;
OFCondition result = i2d.convert(inputPlug, outPlug, dataset, writeXfer);
The second I will get pixelData in dataset and using putAndInsertUint8Array in the dicomfile refference from http://support.dcmtk.org/wiki/dcmtk/how ... essed-data, after I can not open the dicom.
Who is online
Users browsing this forum: Ahrefs [Bot], Baidu [Spider] and 1 guest