Problems with DicomImage

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
juan_7_89
Posts: 15
Joined: Sat, 2013-06-15, 05:52

Problems with DicomImage

#1 Post by juan_7_89 »

Hi! I'm having problems using DicomImage. I have wrote this code and it works well
#include <stdio.h>
#include "dcmtk/config/osconfig.h"
#include "dcmtk/dcmdata/dctk.h"

#include "dcmtk/dcmimage/diregist.h" /* include to support color images */
#include "dcmtk/dcmimgle/dcmimage.h" /* for DicomImage */




using namespace std;
//using namespace cimg_library;

int main(int argc, char *argv[]) {
//Clase que maneja los archivos (cabeceras + datos)
DcmFileFormat FileFormat;
//abrimos el archivo y guardamos el estado de la apertura
OFCondition status = FileFormat.loadFile("test3.dcm");

if (status.good())
{
const Uint16 * pixelData = NULL;
Uint16 lRows = 0;
Uint16 lCols = 0;

//clase que maneja los datos (valores de los pixeles)
DcmDataset *lDataset = FileFormat.getDataset();

//leemos atributos (pixeldata, lrows, lcols);
lDataset->findAndGetUint16Array(DCM_PixelData, pixelData);
lDataset->findAndGetUint16(DCM_Rows, lRows);
lDataset->findAndGetUint16(DCM_Columns, lCols);

cout<< lCols*lRows;

} else
cerr << "Error: cannot read DICOM file (" << status.text() << ")" << endl;

return 0;
}
but when I change the code and add a line with "DicomImage ("test.dcm")" i've got some errors.

This is the final code:
#include <stdio.h>
#include "dcmtk/config/osconfig.h"
#include "dcmtk/dcmdata/dctk.h"

#include "dcmtk/dcmimage/diregist.h" /* include to support color images */
#include "dcmtk/dcmimgle/dcmimage.h" /* for DicomImage */




using namespace std;
//using namespace cimg_library;

int main(int argc, char *argv[]) {
//Clase que maneja los archivos (cabeceras + datos)
DcmFileFormat FileFormat;
DicomImage ("test.dcm");
//abrimos el archivo y guardamos el estado de la apertura
OFCondition status = FileFormat.loadFile("test3.dcm");

if (status.good())
{
const Uint16 * pixelData = NULL;
Uint16 lRows = 0;
Uint16 lCols = 0;

//clase que maneja los datos (valores de los pixeles)
DcmDataset *lDataset = FileFormat.getDataset();

//leemos atributos (pixeldata, lrows, lcols);
lDataset->findAndGetUint16Array(DCM_PixelData, pixelData);
lDataset->findAndGetUint16(DCM_Rows, lRows);
lDataset->findAndGetUint16(DCM_Columns, lCols);

cout<< lCols*lRows;

} else
cerr << "Error: cannot read DICOM file (" << status.text() << ")" << endl;



return 0;
}
this is the message:
/usr/local/include/dcmtk/dcmimage/diregist.h:90: error: undefined reference to 'DiRegister::DiRegister()'
/usr/local/include/dcmtk/dcmimage/diregist.h:90: error: undefined reference to 'DiRegister::~DiRegister()'

and this is my MakeFile
GPP=g++
GCC=gcc
FLAGS= -fshow-column -g2 -Wall -O0 -Wall -pedantic-errors -DHAVE_CONFIG_H -O0 -D_DEBUG
LIBS= -L/usr/local/lib -L/usr/local/include -ldcmimgle -ldcmdata -loflog -lofstd -lz -lpthread -lm -lX11
OBJS=Debug/main.o

all: Debug Debug/ImgDicom.bin

clean:
rm -rf ${OBJS} Debug/ImgDicom.bin

Debug/ImgDicom.bin: ${OBJS}
${GPP} ${OBJS} ${LIBS} -o $@

Debug:
mkdir Debug

Debug/main.o: main.cpp CImg.h
${GPP} ${FLAGS} -c main.cpp -o $@


Can anyone help me?
Thanks!

EDIT: It works if i supress the header #include "dcmtk/dcmimage/diregist.h"

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

Re: Problems with DicomImage

#2 Post by J. Riesmeier »

Of course, if you include a header file from the "dcmimage" module, you also have to link the corresponding library (dcmimage). So, if you need support for color images, add "dcmimage" (and include "diregist.h").

juan_7_89
Posts: 15
Joined: Sat, 2013-06-15, 05:52

Re: Problems with DicomImage

#3 Post by juan_7_89 »

Thanks! I'm now having problems with this
#include <stdio.h>
#include "dcmtk/config/osconfig.h"
#include "dcmtk/dcmdata/dctk.h"

#include "dcmtk/dcmimage/diregist.h"
//libreria para manejar el dataset
#include "dcmtk/dcmimgle/dcmimage.h" /* for DicomImage */

//libreria para manejar las decodificaciones
#include "dcmtk/dcmjpls/djdecode.h"




using namespace std;
//using namespace cimg_library;

int main(int argc, char *argv[]) {
//funcion que determina varios parametros de decodificacion
DJLSDecoderRegistration::registerCodecs();
//Clase que maneja los archivos (cabeceras + datos)
DcmFileFormat FileFormat;
//Clase que sólo la imagen dicom!
DicomImage ("test.dcm");
and this is the error message
usr/local/lib/libdcmjpls.a(djcodecd.o):djcodecd.cc:function DJLSDecoderBase::decodeFrame(DcmPixelSequence*, DJLSCodecParameter const*, DcmItem*, unsigned int, unsigned int&, void*, unsigned int, int, unsigned short, unsigned short, unsigned short, unsigned short): error: undefined reference to 'JpegLsReadHeader'
/usr/local/lib/libdcmjpls.a(djcodecd.o):djcodecd.cc:function DJLSDecoderBase::decodeFrame(DcmPixelSequence*, DJLSCodecParameter const*, DcmItem*, unsigned int, unsigned int&, void*, unsigned int, int, unsigned short, unsigned short, unsigned short, unsigned short): error: undefined reference to 'JpegLsDecode'
i'm including this libs:
ijg8 ijg12 ijg16 dcmimgle dcmimage dcmjpls dcmdata oflog ofstd z pthread m X11
Am i missing a header?

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

Re: Problems with DicomImage

#4 Post by J. Riesmeier »

You have registered the JPEG-LS decoders but link the JPEG libraries. These are two totally different compression schemes!

juan_7_89
Posts: 15
Joined: Sat, 2013-06-15, 05:52

Re: Problems with DicomImage

#5 Post by juan_7_89 »

you are right! Thanks again!

and what libs do i need? because my error message is this now:
/home/juampi/projects/ImgDicom/main.cpp:20: error: undefined reference to 'DJDecoderRegistration::registerCodecs(E_DecompressionColorSpaceConversion, E_UIDCreation, E_PlanarConfiguration, bool)'
/home/juampi/projects/ImgDicom/main.cpp:48: error: undefined reference to 'DJDecoderRegistration::cleanup()'

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

Re: Problems with DicomImage

#6 Post by J. Riesmeier »

I guess that "dcmjpeg" is missing. Also see FAQ #27.

juan_7_89
Posts: 15
Joined: Sat, 2013-06-15, 05:52

Re: Problems with DicomImage

#7 Post by juan_7_89 »

Thank you very much!
That was the problem

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest