DCMTK JPEGLIB8 Error - DICOM

This is a discussion on DCMTK JPEGLIB8 Error - DICOM ; Hi, This example is given in the DCMTK documentation (mod_dcmjpeg.html) #include "djencode.h" #include "djeijg8.h" #include "dctk.h" #include "dcmimage.h" #include "dipijpeg.h" #include "jpeglib8.h" #include "djrplol.h" /*---------------------------------------------*/ DJEncoderRegistration::registerCodecs(); // register JPEG codecs DcmFileFormat fileformat; if (fileformat.loadFile("test.dcm").good()) { DcmDataset *dataset = fileformat.getDataset(); DcmItem ...

+ Reply to Thread
Results 1 to 12 of 12

Thread: DCMTK JPEGLIB8 Error

  1. DCMTK JPEGLIB8 Error

    Hi,
    This example is given in the DCMTK documentation (mod_dcmjpeg.html)


    #include "djencode.h"
    #include "djeijg8.h"
    #include "dctk.h"
    #include "dcmimage.h"
    #include "dipijpeg.h"
    #include "jpeglib8.h"
    #include "djrplol.h"


    /*---------------------------------------------*/

    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_JPEGProcess14SV1TransferS yntax,
    &params);

    // 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

    /*---------------------------------------------*/


    I tried compiling it with
    g++ test.cpp -Idcmjpeg/libijg8 -Idcmimage/include -Idcmjpeg/include
    -Iconfig/include -Iofstd/include -Idcmdata/include/
    -Idcmimgle/include/ -Ldcmjpeg/libijg8 -Ldcmimage/libsrc
    -Ldcmjpeg/libsrc -Lofstd/libsrc -Ldcmdata/libsrc -Ldcmimgle/libsrc
    -lijg8 -ldcmimage -ldcmjpeg -ldcmimgle -ldcmdata -lofstd -lrt
    -lpthread -lnsl -lm -lz -Wno-deprecated

    Even though I have included all the related files, the compiler is
    unable to find jpeg8_std_error, jpeg8_Create_Compress, etc.
    i.e. jpeg8_*

    Please tell me if I should include some other header files as well.

    Regards,
    Kaustubh

  2. Re: DCMTK JPEGLIB8 Error

    Kaustubh wrote:

    > I tried compiling it with
    > g++ test.cpp -Idcmjpeg/libijg8 -Idcmimage/include -Idcmjpeg/include
    > -Iconfig/include -Iofstd/include -Idcmdata/include/
    > -Idcmimgle/include/ -Ldcmjpeg/libijg8 -Ldcmimage/libsrc
    > -Ldcmjpeg/libsrc -Lofstd/libsrc -Ldcmdata/libsrc -Ldcmimgle/libsrc
    > -lijg8 -ldcmimage -ldcmjpeg -ldcmimgle -ldcmdata -lofstd -lrt
    > -lpthread -lnsl -lm -lz -Wno-deprecated


    > Even though I have included all the related files, the compiler is
    > unable to find jpeg8_std_error, jpeg8_Create_Compress, etc.
    > i.e. jpeg8_*


    I guess you mean linker errors not compiler errors. If this is the case
    you should try to change the library order to

    -ldcmjpeg -lijg8 -ldcmimage -ldcmimgle -ldcmdata -lofstd ...

    because "dcmjpeg" depends on "ijg8".

    Regards,
    Joerg Riesmeier
    OFFIS

  3. Re: DCMTK JPEGLIB8 Error

    "Joerg Riesmeier" wrote in message news:...
    >
    > I guess you mean linker errors not compiler errors. If this is the case
    > you should try to change the library order to
    >
    > -ldcmjpeg -lijg8 -ldcmimage -ldcmimgle -ldcmdata -lofstd ...
    >
    > because "dcmjpeg" depends on "ijg8".
    >
    > Regards,
    > Joerg Riesmeier
    > OFFIS


    Thanks for that info. It works!
    Please see the following snippet :
    /*---------------------------*/
    #include "dctk.h"
    #include "dcmimage.h"
    #include "djencode.h"
    #include "dipijpeg.h"
    #include "jpeglib8.h"

    #include "djeijg8.h"
    #include "djrplol.h"
    int main()
    {
    DicomImage *di = new DicomImage("t.dcm");
    DiJPEGPlugin plugin;
    unsigned int opt_quality = 90;
    E_SubSampling opt_sampling = ESS_422;
    plugin.setQuality(opt_quality);
    plugin.setSampling(opt_sampling);

    if (!(di->writePluginFormat(&plugin,"t.jpg")))
    printf ("\n\t Error Using Plugin !\n\t");

    delete di;
    }
    /*---------------------------*/

    It generates an error while writing the plugin and the output is t.jpg
    with 0 bytes and the message Error Using Plugin!
    What could be the problem?

    Regards,
    Kaustubh

  4. Re: DCMTK JPEGLIB8 Error

    Kaustubh wrote:

    > It generates an error while writing the plugin and the output
    > is t.jpg with 0 bytes and the message Error Using Plugin!
    > What could be the problem?


    You did not check whether the DICOM image could be loaded successfully
    using (di->getStatus() == EIS_Normal). In addition, you should enable
    the output of debug messages (see DicomImageClass::setDebugLevel()).

    Regards,
    Joerg Riesmeier
    OFFIS

  5. Re: DCMTK JPEGLIB8 Error

    "Joerg Riesmeier" wrote in message news:...
    >


    >
    > You did not check whether the DICOM image could be loaded successfully
    > using (di->getStatus() == EIS_Normal).



    I checked the status; the file could not be loaded successfully because,
    "No Data Dictionary"
    I have set the variable DCM_DICT_DEFAULT_PATH "/usr/local/dicom/lib/dicom.dic"
    in my program and osconfig.h as well.
    But still it is unable to locate the data dictionary !

    Regards,
    Kaustubh

  6. Re: DCMTK JPEGLIB8 Error

    Kaustubh wrote:

    > I have set the variable DCM_DICT_DEFAULT_PATH
    > "/usr/local/dicom/lib/dicom.dic"
    > in my program and osconfig.h as well.


    You usually do not need to change DCM_DICT_DEFAULT_PATH directly.
    Just set the environment variable DCMDICTPATH accordingly (see
    file "datadict.txt" for details).

    > But still it is unable to locate the data dictionary !


    In the source code package the data dictionary "dicom.dic" is
    located in "dcmdata/libsrc". After you've called "make install"
    the dictionary can be found in "/usr/local/dicom/lib" (depending
    on what you've specified as the installation prefix, though).

    Regards,
    Joerg Riesmeier
    OFFIS

  7. Re: DCMTK JPEGLIB8 Error

    "Joerg Riesmeier" wrote in message news:...
    > Kaustubh wrote:
    >
    > > I have set the variable DCM_DICT_DEFAULT_PATH
    > > "/usr/local/dicom/lib/dicom.dic"
    > > in my program and osconfig.h as well.

    >
    > You usually do not need to change DCM_DICT_DEFAULT_PATH directly.
    > Just set the environment variable DCMDICTPATH accordingly (see
    > file "datadict.txt" for details).
    >
    > > But still it is unable to locate the data dictionary !

    >
    > In the source code package the data dictionary "dicom.dic" is
    > located in "dcmdata/libsrc". After you've called "make install"
    > the dictionary can be found in "/usr/local/dicom/lib" (depending
    > on what you've specified as the installation prefix, though).
    >
    > Regards,
    > Joerg Riesmeier
    > OFFIS


    Thanks a ton !
    Happy to see things working ..
    --
    KaU

  8. Location of dicom.dic (was: DCMTK JPEGLIB8 Error)

    Joerg Riesmeier wrote:

    > In the source code package the data dictionary "dicom.dic" is
    > located in "dcmdata/libsrc". After you've called "make install"
    > the dictionary can be found in "/usr/local/dicom/lib" (depending
    > on what you've specified as the installation prefix, though).


    Joerg,

    as far as I can see, dicom.dic is either installed in
    /usr/local/dicom/lib if no --prefix flag is specified, or
    in ${prefix}/lib if --prefix is specified, or in
    ${libdir} if --libdir is specified.

    However, according to the Unix Filesystem Hierarchy Standard
    (see e.g. http://www.pathname.com/fhs/) it's natural place would
    be beneath /usr/share (or /usr/local/share, if installed locally),
    since dicom.dic contains read-only architecture independent
    data.
    It seems there is currently no straighforward way to install
    DCMTK in compliance with the FHS without kludging the build
    scripts in some way.
    I am wondering, if it would make sense to provide an additional
    --dictdir flag, such that dicom.dic can be installed at it's place
    independently of where the object libraries reside.

    Admittedly, this is of no importance for local installations,
    but fixing it would make life easier for Linux distributors who
    intend to package DCMTK for their distribution.

    Best regards - Juergen


  9. Re: Location of dicom.dic

    Juergen Salk wrote:

    > I am wondering, if it would make sense to provide an additional
    > --dictdir flag, such that dicom.dic can be installed at it's place
    > independently of where the object libraries reside.


    Thanks for your report. I will put that to our to-do list for the next
    release. Maybe, the current configure options are sufficient:

    --datadir=DIR read-only architecture-independent data [PREFIX/share]
    --sysconfdir=DIR read-only single-machine data [PREFIX/etc]

    We will think about it.

    Regards,
    Joerg Riesmeier
    OFFIS

  10. Re: Location of dicom.dic

    Joerg Riesmeier wrote:
    > Juergen Salk wrote:
    >
    >> I am wondering, if it would make sense to provide an additional
    >> --dictdir flag, such that dicom.dic can be installed at it's place
    >> independently of where the object libraries reside.

    >
    > Thanks for your report. I will put that to our to-do list for the next
    > release. Maybe, the current configure options are sufficient:
    >
    > --datadir=DIR read-only architecture-independent data [PREFIX/share]
    > --sysconfdir=DIR read-only single-machine data [PREFIX/etc]


    Probably not. Look at config/configure.in:

    if test "x$prefix" = xNONE ; then
    AC_DEFINE_UNQUOTED(DCMTK_PREFIX, "${ac_default_prefix}", [Define ...])
    else
    AC_DEFINE_UNQUOTED(DCMTK_PREFIX, "${prefix}", [Define ... ])
    fi
    AC_DEFINE_UNQUOTED(DCM_DICT_DEFAULT_PATH, DCMTK_PREFIX "/lib/dicom.dic", [Define ...])

    I.e. the DCMTK application tools will always expect dicom.dic in
    /usr/local/dicom/lib or ${prefix}/lib regardless whether it is
    actually installed elsewhere by means of --libdir or any other
    configure option.

    Best regards - Juergen



  11. Re: Location of dicom.dic

    Juergen Salk wrote:

    > Probably not. Look at config/configure.in:

    [...]
    > I.e. the DCMTK application tools will always expect dicom.dic in
    > /usr/local/dicom/lib or ${prefix}/lib regardless whether it is
    > actually installed elsewhere by means of --libdir or any other
    > configure option.


    Yes, I know. This is a known bug that is already listed in our
    to-do list for the next release. Currently, you have to modify
    config/Makefile.def (if required) after the configure process
    is completed.

    Maybe it was not clear what I wanted to say in my last posting:
    I don't think that we need new configure options, we only need
    to change how they are used.

    Regards,
    Joerg Riesmeier



  12. Re: Location of dicom.dic

    Joerg Riesmeier wrote:

    > Maybe it was not clear what I wanted to say in my last posting:
    > I don't think that we need new configure options, we only need
    > to change how they are used.


    True. Once the headers reflect the configure options for the
    dicom.dic installation path everything will be fine.

    Best regards - Juergen

+ Reply to Thread