Unable to compress a dcm file in Linux (CentOS7)
Moderator: Moderator Team
-
- Posts: 9
- Joined: Tue, 2017-07-04, 09:27
Unable to compress a dcm file in Linux (CentOS7)
Hi,
I am using dcmtk3.6.0, i am not able to compress any file.
Return value of chooseRepresentation api is "Illegal call, perhaps wrong parameters"
Original transfer syntax: Explicit VR Little Endian
Target Transfer syntax: JPEG Lossless, Nonhierarchical, First- Order Prediction(Processes 14 [Selection Value 1])
I am using CentOS 7.
What could be the possible reasons?
Regards,
I am using dcmtk3.6.0, i am not able to compress any file.
Return value of chooseRepresentation api is "Illegal call, perhaps wrong parameters"
Original transfer syntax: Explicit VR Little Endian
Target Transfer syntax: JPEG Lossless, Nonhierarchical, First- Order Prediction(Processes 14 [Selection Value 1])
I am using CentOS 7.
What could be the possible reasons?
Regards,
-
- DCMTK Developer
- Posts: 2503
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: Unable to compress a dcm file in Linux (CentOS7)
Does it work to compress this particular DICOM image file with "dcmcjpeg", i.e. from the command line?
-
- Posts: 9
- Joined: Tue, 2017-07-04, 09:27
Re: Unable to compress a dcm file in Linux (CentOS7)
Yes, it works while using dcmcjpeg from terminal.
-
- DCMTK Developer
- Posts: 2503
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: Unable to compress a dcm file in Linux (CentOS7)
OK, did you make sure that the JPEG encoders are registered to your program? See example in the documentation for details.
-
- Posts: 9
- Joined: Tue, 2017-07-04, 09:27
Re: Unable to compress a dcm file in Linux (CentOS7)
Yes they are registered.
Here is the code I am using:
int DcmtkDicomInterface::ConvertDicom(std::string inputFile, std::string outputFile)
{
DJEncoderRegistration::registerCodecs();
OFCondition chooseRepresentationStatus;
DcmFileFormat fileformat;
if (fileformat.loadFile(inputFile.c_str()).good())
{
RAD_LOG_INFO("Processing DICOM file " << inputFile.c_str());
DcmDataset *dataset = fileformat.getDataset();
DcmItem *metaInfo = fileformat.getMetaInfo();
DJ_RPLossless params;
chooseRepresentationStatus = dataset->chooseRepresentation(EXS_JPEGProcess14SV1TransferSyntax, ¶ms);
RAD_LOG_CRITICAL("Choose Representation status is : " << chooseRepresentationStatus.text());
if (dataset->canWriteXfer(EXS_JPEGProcess14SV1TransferSyntax))
{
RAD_LOG_INFO("Can write JPEG lossless");
// 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(outputFile.c_str(), EXS_JPEGProcess14SV1TransferSyntax);
DJEncoderRegistration::cleanup();
return 1;
}
DJEncoderRegistration::cleanup();
return (-1);
}
}
Here is the code I am using:
int DcmtkDicomInterface::ConvertDicom(std::string inputFile, std::string outputFile)
{
DJEncoderRegistration::registerCodecs();
OFCondition chooseRepresentationStatus;
DcmFileFormat fileformat;
if (fileformat.loadFile(inputFile.c_str()).good())
{
RAD_LOG_INFO("Processing DICOM file " << inputFile.c_str());
DcmDataset *dataset = fileformat.getDataset();
DcmItem *metaInfo = fileformat.getMetaInfo();
DJ_RPLossless params;
chooseRepresentationStatus = dataset->chooseRepresentation(EXS_JPEGProcess14SV1TransferSyntax, ¶ms);
RAD_LOG_CRITICAL("Choose Representation status is : " << chooseRepresentationStatus.text());
if (dataset->canWriteXfer(EXS_JPEGProcess14SV1TransferSyntax))
{
RAD_LOG_INFO("Can write JPEG lossless");
// 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(outputFile.c_str(), EXS_JPEGProcess14SV1TransferSyntax);
DJEncoderRegistration::cleanup();
return 1;
}
DJEncoderRegistration::cleanup();
return (-1);
}
}
-
- DCMTK Developer
- Posts: 2503
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: Unable to compress a dcm file in Linux (CentOS7)
Further questions: What does the DEBUG logger show?
Did you make sure that the data dictionary is loaded?
The latter can be checked with the following code (from "dcmdata.cc"):
Did you make sure that the data dictionary is loaded?
The latter can be checked with the following code (from "dcmdata.cc"):
Code: Select all
/* make sure data dictionary is loaded */
if (!dcmDataDict.isDictionaryLoaded())
{
OFLOG_WARN(dcmdumpLogger, "no data dictionary loaded, check environment variable: "
<< DCM_DICT_ENVIRONMENT_VARIABLE);
}
-
- Posts: 9
- Joined: Tue, 2017-07-04, 09:27
Re: Unable to compress a dcm file in Linux (CentOS7)
Data dictionary was not loaded.
It didn't work even though the environment variable 'DCMDICTPATH' was set to the dicom.dic file.
I rebuilt dcmtk libraries with the flag 'DCMTK_ENABLE_BUILTIN_DICTIONARY' enabled in CMake.
Now its working.
THANK YOU for your help.
It didn't work even though the environment variable 'DCMDICTPATH' was set to the dicom.dic file.
I rebuilt dcmtk libraries with the flag 'DCMTK_ENABLE_BUILTIN_DICTIONARY' enabled in CMake.
Now its working.
THANK YOU for your help.
Who is online
Users browsing this forum: Google [Bot] and 1 guest