jpeg200 not identified

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
George
Posts: 54
Joined: Sun, 2023-11-12, 16:50

jpeg200 not identified

#1 Post by George »

Hello,

This is the below code does not identify the attached nanox file as jpeg2000 can you assist and tell us why? I think the command ataset->findAndGetString(DCM_TransferSyntaxUID, transferSyntax).good()
do not work good?

https://drive.google.com/file/d/1Eld9fU ... drive_link

Code: Select all

bool isJPEG2000TransferSyntax(const std::string& filePath) {


    LOG("entered the isJPEG2000TransferSyntax function");
    DcmFileFormat fileFormat;
    OFCondition status = fileFormat.loadFile(filePath.c_str());
    LOG("loaded the file");
    if (status.good()) {
        // Retrieve the dataset from the file
        DcmDataset *dataset = fileFormat.getDataset();
        LOG("status is good");
        // Get the transfer syntax
        const char *transferSyntax;
        LOG("dataset->findAndGetString(DCM_TransferSyntaxUID, transferSyntax).good()=", dataset->findAndGetString(DCM_TransferSyntaxUID, transferSyntax).good(), true);

    OFBool status = dataset->findAndGetString(DCM_TransferSyntaxUID, transferSyntax).good();
    LOG((bool)status, true);
    if (status) {
        // Successfully retrieved the Transfer Syntax

        if (dataset->findAndGetString(DCM_TransferSyntaxUID, transferSyntax).good()) {
            std::string transferSyntaxStr(transferSyntax);

            LOG("transferSyntaxStr is ", transferSyntaxStr);

            // Check if the transfer syntax corresponds to JPEG2000
            // JPEG 2000 Lossless: "1.2.840.10008.1.2.4.90"
            // JPEG 2000 Lossy (ISO 15444-1): "1.2.840.10008.1.2.4.91"
            if (transferSyntaxStr == "1.2.840.10008.1.2.4.90" || transferSyntaxStr == "1.2.840.10008.1.2.4.91") {
                return true; // The file uses JPEG2000 transfer syntax
            }
        }
    } else {
        //std::cerr << "Error: Cannot load DICOM file (" << status.text() << ")" << std::endl;
    }
   }

    return false; // The file does not use JPEG2000 transfer syntax or an error occurred
}
      

Michael Onken
DCMTK Developer
Posts: 2059
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: jpeg200 not identified

#2 Post by Michael Onken »

dataset->findAndGetString(DCM_TransferSyntaxUID, transferSyntax).good();
The transfer syntax is not part of the Dataset but is part of the metaheader. I did not check the rest of the code carefully.
Use instead:

Code: Select all

DcmMetaInfo *dataset = fileFormat.getMetaInfo();
George, please also put some effort into solving your problems yourself... Using dcmdump on the file it should be obvious that the transfer syntax cannot be found in the dataset.

BR Michael

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest