About the saving processing of the Lossless JPEG image
Moderator: Moderator Team
-
- Posts: 4
- Joined: Fri, 2005-02-18, 03:18
- Location: Tokyo, Japan
About the saving processing of the Lossless JPEG image
Hi, everybody!
I am trying the saving of the Lossless JPEG image.
(At this time, it uses the copy constructor of DcmFileFormat)
When copied DcmFileFormat is saved, PixelData of the saved file is lost.
Condition:
TransferSyntaxUID is "1.2.840.10008.1.2.70".
How should be done the saving processing?
Thanks.
I am trying the saving of the Lossless JPEG image.
(At this time, it uses the copy constructor of DcmFileFormat)
When copied DcmFileFormat is saved, PixelData of the saved file is lost.
Condition:
TransferSyntaxUID is "1.2.840.10008.1.2.70".
How should be done the saving processing?
Thanks.
-
- OFFIS DICOM Team
- Posts: 1445
- Joined: Tue, 2004-11-02, 17:22
- Location: Oldenburg, Germany
- Contact:
I would suggest that you look at the implementation of the dcmcjpeg tool. If your source image is created in uncompressed form, you will need to convert it to lossless JPEG representation before you can save in lossless JPEG format. This requires that you register the lossless JPEG codec at runtime and call chooseRepresentation() on the dataset prior to storing the file.
-
- Posts: 4
- Joined: Fri, 2005-02-18, 03:18
- Location: Tokyo, Japan
It goes according to the following procedures.
1.The source image is made in the shape that has already been compressed.
2.The source image is read with DcmFileFormat.
3.New DcmFileFormat is made by handling the copy constructor from read DcmFileFormat.
4.New DcmFileFormat is saved in the file.
5.PixelData of the saved file is lost.
At which stage does it only have to be executed chooseRepresentation()?
PixelData has been lost though chooseRepresentation() was executed ahead of No.4.
1.The source image is made in the shape that has already been compressed.
2.The source image is read with DcmFileFormat.
3.New DcmFileFormat is made by handling the copy constructor from read DcmFileFormat.
4.New DcmFileFormat is saved in the file.
5.PixelData of the saved file is lost.
At which stage does it only have to be executed chooseRepresentation()?
PixelData has been lost though chooseRepresentation() was executed ahead of No.4.
-
- ICSMED DICOM Services
- Posts: 2217
- Joined: Fri, 2004-10-29, 21:38
- Location: Oldenburg, Germany
The following example is part of the toolkit's documentation:
If you need a more complex example have a look at the implementation of "dcmcjpeg"!
Code: Select all
DJEncoderRegistration::registerCodecs(); // register JPEG codecs
DcmFileFormat fileformat;
if (fileformat.loadFile("test.dcm").good())
{
DcmDataset *dataset = fileformat.getDataset();
DcmItem *metaInfo = fileformat.getMetaInfo();
DJ_RPLossless params; // codec parameters, we use the defaults
// this causes the lossless JPEG version of the dataset to be created
dataset->chooseRepresentation(EXS_JPEGProcess14SV1TransferSyntax, ¶ms);
// check if everything went well
if (dataset->canWriteXfer(EXS_JPEGProcess14SV1TransferSyntax))
{
// force the meta-header UIDs to be re-generated when storing the file
// since the UIDs in the data set may have changed
delete metaInfo->remove(DCM_MediaStorageSOPClassUID);
delete metaInfo->remove(DCM_MediaStorageSOPInstanceUID);
// store in lossless JPEG format
fileformat.saveFile("test_jpeg.dcm", EXS_JPEGProcess14SV1TransferSyntax);
}
}
DJEncoderRegistration::cleanup(); // deregister JPEG codecs
-
- Posts: 4
- Joined: Fri, 2005-02-18, 03:18
- Location: Tokyo, Japan
This time codes it as follows.
PixelData is lost when doing according to this procedure.
Cannot DcmFileFormat of copied Lossless JPEG be preserved?
Code: Select all
DJEncoderRegistration::registerCodecs(); // register JPEG codecs
DcmFileFormat fileformat;
if (fileformat.loadFile("test.dcm").good())
{
//new DcmFileFormat is created by a opened file.
DcmFileFormat* pFileFormat = new DcmFileFormat(fileformat);
DcmDataset *dataset = pFileFormat->getDataset();
DcmItem *metaInfo = pFileFormat->getMetaInfo();
DJ_RPLossless params;
dataset->chooseRepresentation(EXS_JPEGProcess14SV1TransferSyntax, ¶ms);
if (dataset->canWriteXfer(EXS_JPEGProcess14SV1TransferSyntax))
{
delete metaInfo->remove(DCM_MediaStorageSOPClassUID);
delete metaInfo->remove(DCM_MediaStorageSOPInstanceUID);
pFileFormat->saveFile("test_jpeg.dcm", EXS_JPEGProcess14SV1TransferSyntax);
}
}
DJEncoderRegistration::cleanup(); // deregister JPEG codecs
Cannot DcmFileFormat of copied Lossless JPEG be preserved?
-
- ICSMED DICOM Services
- Posts: 2217
- Joined: Fri, 2004-10-29, 21:38
- Location: Oldenburg, Germany
This is a known bug of DCMTK 3.5.3 which will be fixed in the next release:
Why do you create a copy of "fileformat" anyway?
Code: Select all
**** Changes from 2004.07.01 (eichelberg)
- Fixed copy constructor for class DcmPixelData which did not work correctly
under certain circumstances due to an uninitialized attribute.
Affects: dcmdata/libsrc/dcpixel.cc
-
- Posts: 4
- Joined: Fri, 2005-02-18, 03:18
- Location: Tokyo, Japan
A loaded file might be edited.
It occasionally save a file by a different file name.
When saving a file, original "ImplementationVersionName" is added.
Loaded DcmFileFormat is used for a display.
Therefore, the display is likely to differ from DcmFileFormat that executed saveFile() and a file of real existence.
Is there something good idea?
It occasionally save a file by a different file name.
When saving a file, original "ImplementationVersionName" is added.
Loaded DcmFileFormat is used for a display.
Therefore, the display is likely to differ from DcmFileFormat that executed saveFile() and a file of real existence.
Is there something good idea?
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest