dicom file problem

All other questions regarding DCMTK

Moderator: Moderator Team

Message
Author
jlseminara
Posts: 8
Joined: Mon, 2005-05-09, 17:27
Location: argentina, buenos aires
Contact:

dicom file problem

#1 Post by jlseminara »

Hi everyone ... I'm back (with more problems of course)

I could developed a DICOM writer system (reads a Bitmap and generate a .dcm file) using DCMTK. At this point I can write a dicom file with its header and pixel data. The problem is when I try to read it with some dicom readers the image is shown perfectly but with others programs I get a whole white image.(I get a white image with eFilm Medical Inc. product). Here is the code. I Would really appreciate any suggestion because I'm clueless

Code: Select all

#include <diregist.h>
#include <diutils.h>
#include <dcmimage.h>
#include <dcdeftag.h>
#include <ofstdinc.h>
#include <ofstd.h>
#include <ofcond.h>
#include <dcfilefo.h>
#include <dcdatset.h>

void main(void)
{

BITMAPFILEHEADER bmpFH;
BITMAPINFOHEADER bmpIH;
unsigned char *contenidoBMP;
FILE *imagen;

if ( (imagen = fopen("1.bmp","r+")) == NULL )
{
	printf("no existe");
	exit(0);
}

fread(&bmpFH,sizeof(bmpFH),1,imagen);
fread(&bmpIH,sizeof(bmpIH),1,imagen);
fseek(imagen, bmpFH.bfOffBits, SEEK_SET);

contenidoBMP = (unsigned char *) malloc( bmpIH.biSizeImage );
fread(contenidoBMP, bmpIH.biSizeImage ,1,imagen);

DcmFileFormat fileformat;
DcmDataset *dataset = fileformat.getDataset();


/////////////////////////////////
dataset->putAndInsertString(DCM_SOPClassUID, "SOPClassUID");		
dataset->putAndInsertString(DCM_SOPInstanceUID, "SOPInstanceUID");	
/////////////////////////////////
dataset->putAndInsertString(DCM_PatientsName, "Test Dicom");
dataset->putAndInsertString(DCM_PatientID,"");
dataset->putAndInsertString(DCM_PatientsBirthDate,"");
dataset->putAndInsertString(DCM_PatientsSex,"");
//////////////////////////////////
dataset->putAndInsertString(DCM_StudyInstanceUID,"StudyInstanceUID");	
dataset->putAndInsertString(DCM_StudyDate,"");
dataset->putAndInsertString(DCM_StudyTime,"");
dataset->putAndInsertString(DCM_StudyID,"");
dataset->putAndInsertString(DCM_ReferringPhysiciansName,"");
////////////////////////////////
dataset->putAndInsertString(DCM_SeriesInstanceUID,"SeriesInstanceUID");	
dataset->putAndInsertString(DCM_SeriesNumber,"");
dataset->putAndInsertString(DCM_Modality,"Modality");
dataset->putAndInsertString(DCM_Manufacturer,"");
dataset->putAndInsertString(DCM_InstitutionName,"");
////////////////////////////////
dataset->putAndInsertString(DCM_ImageID,"ImageID");
dataset->putAndInsertString(DCM_InstanceNumber,"");
dataset->putAndInsertString(DCM_ImageType,"");                       
////////////////////////////////
dataset->putAndInsertString(DCM_BitsAllocated,"8");
dataset->putAndInsertString(DCM_BitsStored,"8");
dataset->putAndInsertString(DCM_HighBit,"0");
dataset->putAndInsertString(DCM_Rows,"576");
dataset->putAndInsertString(DCM_Columns,"768");
dataset->putAndInsertString(DCM_SamplesPerPixel,"1");
dataset->putAndInsertString(DCM_PlanarConfiguration,"1");
dataset->putAndInsertString(DCM_PixelRepresentation,"0");			
dataset->putAndInsertString(DCM_PhotometricInterpretation,"MONOCHROME2"); 
//////////////////////////////
//////////////////////////////
dataset->putAndInsertUint8Array(DCM_PixelData, contenidoBMP, bmpIH.biSizeImage);
/////////////////////////////////////////////////
dataset->putAndInsertString(DCM_WindowCenter,"");
dataset->putAndInsertString(DCM_WindowWidth,"");
//////////////// Saving the file ////////////////
OFCondition status = fileformat.saveFile("test.dcm", EXS_LittleEndianExplicit);

fclose(imagen);
}

Sincerely,
Leonardo Seminara

AndreasKnopke
Posts: 49
Joined: Wed, 2005-02-16, 16:27

#2 Post by AndreasKnopke »

Hello Leonardo,

the High bits value "0" seems strange. See Dicom part 3. I would suggest "7". Maybe this is the problem.
Btw. the header you create is not compliant to the standard because many mandatory items are either missing or filled with inappropriate values.

Andreas

jlseminara
Posts: 8
Joined: Mon, 2005-05-09, 17:27
Location: argentina, buenos aires
Contact:

#3 Post by jlseminara »

Thanks again for your help ... I've already solved the problem: there was indeed some mandatory tags missing and some values wrong in other tags.
If someone is interested I can share de code, it’s an easy application that generates a dicom file from a BMP.

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#4 Post by Jörg Riesmeier »

Btw, why are you putting strings into numeric data elements? Although these values should be converted automatically by the underlying DCMTK routines it would be better to use the appropriate putAndInsertXXX() methods.

jlseminara
Posts: 8
Joined: Mon, 2005-05-09, 17:27
Location: argentina, buenos aires
Contact:

#5 Post by jlseminara »

The code I showed before is just a test, my real application is most solid, beside I did that because I wanted to know if it works ... I mean save the header as string tags and find if the file could still be processed by a dicom viewer. As I supposed the code I showed works perfectly ... now I'm trying to find when (in what cases) the way I did it wouldn't work (just for fun)
My real work now is trying to insert several images into the dicom file (a sequence)

Regards,
Leonardo Seminara
Universidad Argentina de la Empresa
www.uade.edu.ar
Buenos Aires, Argentina

bbishara
Posts: 2
Joined: Tue, 2005-07-05, 18:38

help

#6 Post by bbishara »

I am trying to write a dicom image based on a 2d array with each pixel being an 8bit unsigned #, I have no idea how ot link or use dicom and any help woudl be greatly appreciated,

I know there is a function that saves images based on a pointer in the dcmpstat , dviface.cxx file but I do not know how to call the function from my onw project or how to link anytihng, any help is appreciated :)


Mark

Manish
Posts: 6
Joined: Mon, 2005-12-05, 06:53

Need Code

#7 Post by Manish »

Hello Leonardo Seminara:

I am interested in your DICOM writer system (which takes a .bmp file and generates a DICOM file).

Could you send your code to kishor.manish@gmail.com


Best Regards,
Manish

Manish
Posts: 6
Joined: Mon, 2005-12-05, 06:53

#8 Post by Manish »

Hello All:

In the above Leonardo's code what are the missing mandatory tags and which of mandatory tag values has been incorrectly assigned?

Actually I am trying to create a DICOM image file from a BMP file. I have taken Leonardo's code as reference. While opening the generated DICOM image file using ezDicom viewer I get "I/O Error 103".

In the above code what are the values taken by the attribute such as DCM_ImageID, DCM_InstanceNumber, DCM_ImageType.

I am new to DICOM and I am clueless to all these. Please try to resolve my queries.

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1445
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

#9 Post by Marco Eichelberg »

The most important problem with the code above is that all UIDs are invalid. For example, attribute DCM_SOPClassUID must not contain the value "DCM_SOPClassUID" but the string constant UID_SecondaryCaptureImageStorage. All other UIDs should be generated with dcmGenerateUniqueIdentifier(). There may be more problems that I have not seen, though.

walohanet
Posts: 1
Joined: Fri, 2005-12-09, 04:17

#10 Post by walohanet »

I am interesting in you project.Could you sent your code to me for a reference. I am assure that it is just for study
w.alohanet@gmail.com

sincerely

Manish
Posts: 6
Joined: Mon, 2005-12-05, 06:53

#11 Post by Manish »

Thanks for your reply. I was able to solve the bug. However I am not able to assign value to DCM_PatientsName attribute. I am getting the I/O error (while opening with ezDicom viewer) even if this attribute is assigned with NULL. If I comment this attribute I am not getting any errors while opening with ezDicom. I am not getting any error if I open with an alternate viewer(ImageJ).

alang88
Posts: 5
Joined: Sat, 2005-12-24, 14:03

#12 Post by alang88 »

Manish wrote:Thanks for your reply. I was able to solve the bug. However I am not able to assign value to DCM_PatientsName attribute. I am getting the I/O error (while opening with ezDicom viewer) even if this attribute is assigned with NULL. If I comment this attribute I am not getting any errors while opening with ezDicom. I am not getting any error if I open with an alternate viewer(ImageJ).
Ok, could you give me a copy of the list of mandatory items for general DICOM Image viewers!! alang88@gmail.com ,thanks!

AndreasKnopke
Posts: 49
Joined: Wed, 2005-02-16, 16:27

#13 Post by AndreasKnopke »

Have a look at DICOM part 3, chapter A.8, secondary capture image object definition. Here you will find all information needed.

to Manish:
I am getting the I/O error (while opening with ezDicom viewer) even if this attribute is assigned with NULL.
Do you still have this problem? If so you can send me an example image (Andreas<at>K-PACS.de) that I can check. My application (K-PACS) uses parts of the ezDicom library and might react in a similar way to your image.

regards,
Andreas

veryhotsauasge
Posts: 7
Joined: Mon, 2006-01-30, 14:06

#14 Post by veryhotsauasge »

Hi,

I would like to get a sample of your dicom saving source code.

please send to veryhotsausage@gmail.com. Thank you so much in advance.

Where can we get documentation on the "DCM_ " parameters? I think more information about DCM_PhotometricInterpretation and DCM_PixelData and the important ones to include would be very helpful.

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1445
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

#15 Post by Marco Eichelberg »

Where can we get documentation on the "DCM_ " parameters? I think more information about DCM_PhotometricInterpretation and DCM_PixelData and the important ones to include would be very helpful.
All DCM_ constants are just aliases for numerical DICOM tags such as (7fe0,0010). The numerical values can be lookup up in dcmtk/dcmdata/dcdeftag.h and their semantics is defined in part 3 of the DICOM standard, which is the best (and only) resource on this topic. Read the definition of the image pixel module, and unless you understand the meaning of "Information Entity", "Module", and "Type 1C Attribute", don't try to create any DICOM object :wink:

Post Reply

Who is online

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