DICOM @ OFFIS

Discussion Forum for OFFIS DICOM Tools - For registration, send email with desired user name to the OFFIS DICOM team
It is currently Sat, 2018-02-24, 23:03

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Wed, 2018-02-07, 07:07 
Offline

Joined: Tue, 2017-07-04, 09:27
Posts: 7
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,


Top
 Profile  
 
PostPosted: Wed, 2018-02-07, 18:13 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1914
Location: Oldenburg, Germany
Does it work to compress this particular DICOM image file with "dcmcjpeg", i.e. from the command line?


Top
 Profile  
 
PostPosted: Thu, 2018-02-08, 06:02 
Offline

Joined: Tue, 2017-07-04, 09:27
Posts: 7
Yes, it works while using dcmcjpeg from terminal.


Top
 Profile  
 
PostPosted: Thu, 2018-02-08, 09:40 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1914
Location: Oldenburg, Germany
OK, did you make sure that the JPEG encoders are registered to your program? See example in the documentation for details.


Top
 Profile  
 
PostPosted: Thu, 2018-02-08, 10:23 
Offline

Joined: Tue, 2017-07-04, 09:27
Posts: 7
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, &params);
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);
}
}


Top
 Profile  
 
PostPosted: Thu, 2018-02-08, 10:29 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1914
Location: Oldenburg, Germany
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"):

Code:
    /* make sure data dictionary is loaded */
    if (!dcmDataDict.isDictionaryLoaded())
    {
      OFLOG_WARN(dcmdumpLogger, "no data dictionary loaded, check environment variable: "
        << DCM_DICT_ENVIRONMENT_VARIABLE);
    }


Top
 Profile  
 
PostPosted: Fri, 2018-02-09, 12:41 
Offline

Joined: Tue, 2017-07-04, 09:27
Posts: 7
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group