android

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
liusunping
Posts: 6
Joined: Mon, 2020-06-22, 12:07

android

#1 Post by liusunping »

When I use DCMTK to parse DCM files, dcmmetainfo can read relevant information such as devices, but in building dicomimage, getstatus is EIS in dicomimage object_ No data dictionary, but this DCM file can be read in windows and IOS . Here is my source code. Can you help me see the cause of the problem

my code

const char *input_pa_name= "/storage/emulated/0/Download/ image-00000.dcm" ;

OFFilename *file= new OFFilename (input_pa_name ,false ) ;

DcmFileFormat *dcmFileFormat = new DcmFileFormat () ;

OFCondition status = dcmFileFormat->loadFile (*file) ;
if ( status .good()) {
OFString patientName ;
DcmDataset *dcmDataset = dcmFileFormat->getDataset() ;
OFCondition condition = dcmDataset-> findAndGetOFString(DCM_ ApplicationManufacturer ,patien tName ) ;
if (condition.good()) {
__android_log_print(ANDROID_ LOG_ERROR , "tag" , "condition.good = %s" , patientName.c_str()
) ;
} else {
__android_log_print(ANDROID_ LOG_ERROR , "tag" , "condition. BAD" ) ;
}
const char *transferSyntax ; DcmMetaInfo *dcmMetaInfo = dcmFileFormat->getMetaInfo() ;
OFCondition transferSyntaxOfCondition = dcmMetaInfo->findAndGetString( DCM_TransferSyntaxUID , transferSyntax) ;
__android_log_print(ANDROID_ LOG_ERROR , "tag" , "transferSyntaxOfCondition %s" , transferSyntaxOfCondition. text()) ;
__android_log_print(ANDROID_ LOG_ERROR , "tag" , "transferSyntax %s" , transferSyntax) ;
// 获得当前的窗宽窗位
Float64 windowCenter ; dcmDataset->findAndGetFloat64( DCM_WindowCenter , windowCenter ) ;
__android_log_print(ANDROID_ LOG_ERROR , "tag" , "windowCenter %f" , windowCenter) ;
Float64 windowWidth ; dcmDataset->findAndGetFloat64( DCM_WindowWidth , windowWidth ) ;
__android_log_print(ANDROID_ LOG_ERROR , "tag" , "windowWidth %f" , windowWidth) ;
E_TransferSyntax xfer = dcmDataset->getOriginalXfer() ;
__android_log_print(ANDROID_ LOG_ERROR , "tag" , "E_TransferSyntax %d" , xfer) ;
const char * model ;
dcmDataset->findAndGetString( DCM_Modality , model) ;
__android_log_print(ANDROID_ LOG_ERROR , "tag" , "-------------Model: %s" , model) ;
std:: string losslessTransUID = "1.2.840.10008.1.2.4.70" ;
std::string lossTransUID = "1.2.840.10008.1.2.4.51" ;
std::string losslessP14 = "1.2.840.10008.1.2.4.57" ;
std::string lossyP1 = "1.2.840.10008.1.2.4.50" ;
std::string lossyRLE = "1.2.840.10008.1.2.5" ;
bool isYaSuo =0 ;
DicomImage *dcmImage = NULL ;
// todo
if (transferSyntax == NULL){
isYaSuo = false; // 无压缩
}
else {
if (transferSyntax == losslessTransUID || transferSyntax == lossTransUID ||
transferSyntax == losslessP14 || transferSyntax == lossyP1) {
// 对压缩的图像像素进行解压
DJDecoderRegistration:: registerCodecs() ;
dcmDataset-> chooseRepresentation(EXS_ LittleEndianExplicit , NULL) ;
DJDecoderRegistration:: cleanup() ;
isYaSuo = true; // 有压缩
} else if (transferSyntax == lossyRLE) {
DcmRLEDecoderRegistration:: registerCodecs() ;
dcmDataset-> chooseRepresentation(EXS_ LittleEndianExplicit , NULL) ;
DcmRLEDecoderRegistration:: cleanup() ;
isYaSuo = true; // 有压缩
} else{
isYaSuo = false; // 无压缩
}
}
long imageHeight = 0 ;
long imageWidth = 0;
if (isYaSuo){
dcmImage = new DicomImage((DcmObject*) dcmDataset , dcmDataset->getOriginalXfer() , CIF_TakeOverExternalDataset) ;
if (dcmImage->getStatus() == EIS_Normal) {
imageWidth = dcmImage->getWidth() ;
imageHeight = dcmImage->getHeight() ;
if (windowWidth < 1 ) {
// 设置窗宽窗位
dcmImage->setRoiWindow( 0 , 0 , imageWidth , imageHeight ) ;
// 重新对winCenter, winWidth 赋值
dcmImage->getWindow( windowCent er , windowWidth ) ;
}
}
} else {
dcmImage = new DicomImage(dcmMetaInfo , dcmDataset->getOriginalXfer() , CIF_TakeOverExternalDataset) ;
if (dcmImage->getStatus() = = EIS_Normal) {
imageWidth = dcmImage->getWidth() ;
imageHeight = dcmImage->getHeight() ;
if (windowWidth < 1 ) {
dcmImage->setRoiWindow( 0 , 0 , imageWidth , imageHeight ) ;
dcmImage->getWindow( windowCent er , windowWidth ) ;
}
}
}

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: android

#2 Post by J. Riesmeier »

EIS in dicomimage object_ No data dictionary
Maybe, the answer is too obvious: the error says that "no data dictionary" was loaded. Windows uses a built-in data dictionary and iOS apparently found the "dicom.dic" file in the default path.

liusunping
Posts: 6
Joined: Mon, 2020-06-22, 12:07

Re: android

#3 Post by liusunping »

I compiled it on WSL (Windows Ubuntu). The package is AndroidStudio on windows. I put dicom.dic Copy it to the directory /storage/emulated/0/Download/ of my phone. When I pack it with AndroidStudio,i change the osconfig.h file /usr/local/share/dcmtk/dicom.dic as #define DCM_DICT_DEFAULT_PATH "/storage/emulated/0/Download/dicom.dic"
,There will still be EIS_ NoDataDictionary

liusunping
Posts: 6
Joined: Mon, 2020-06-22, 12:07

Re: android

#4 Post by liusunping »

J. Riesmeier wrote: Mon, 2020-06-22, 18:24
EIS in dicomimage object_ No data dictionary
Maybe, the answer is too obvious: the error says that "no data dictionary" was loaded. Windows uses a built-in data dictionary and iOS apparently found the "dicom.dic" file in the default path.
I compiled it on WSL (Windows Ubuntu). The package is AndroidStudio on windows. I put dicom.dic Copy it to the directory /storage/emulated/0/Download/ of my phone. When I pack it with AndroidStudio,i change the osconfig.h file /usr/local/share/dcmtk/dicom.dic as #define DCM_DICT_DEFAULT_PATH "/storage/emulated/0/Download/dicom.dic"
,There will still be EIS_ NoDataDictionary

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: android

#5 Post by J. Riesmeier »

When enabling the debug output, you should something like the following on the logger:

Code: Select all

D: DcmDataDictionary: Loading file: /usr/local/share/dcmtk/dicom.dic
Also in your application, you should have something like this check (copied from dcmdump.cc):

Code: Select all

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

liusunping
Posts: 6
Joined: Mon, 2020-06-22, 12:07

Re: android

#6 Post by liusunping »

J. Riesmeier wrote: Wed, 2020-06-24, 08:04 When enabling the debug output, you should something like the following on the logger:

Code: Select all

D: DcmDataDictionary: Loading file: /usr/local/share/dcmtk/dicom.dic
Also in your application, you should have something like this check (copied from dcmdump.cc):

Code: Select all

    if (!dcmDataDict.isDictionaryLoaded())
    {
      OFLOG_WARN(dcmdumpLogger, "no data dictionary loaded, check environment variable: "
        << DCM_DICT_ENVIRONMENT_VARIABLE);
    }
I solved this problem. I know that I don’t have a dictionary, but I don’t know how to add it. Later, I refer to the code of other systems. I added,as this

const char* _dict= "/storage/emulated/0/Download/dicom.dic";
DcmDataDictionary &dict = dcmDataDict.wrlock();
dict.loadDictionary(_dict);
dcmDataDict.wrunlock();

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: android

#7 Post by J. Riesmeier »

Good to know that you've solved your problem. However, it's strange that setting DCM_DICT_DEFAULT_PATH to the same path ("/storage/emulated/0/Download/dicom.dic") and recompiling the DCMTK did not work.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 1 guest