Error in CreateValueFromTempFile Function

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
prakash
Posts: 50
Joined: Mon, 2008-05-19, 10:34
Contact:

Error in CreateValueFromTempFile Function

#1 Post by prakash »

HI ,

I already posted this message in some other tag.
By mistake i posted this message there.
Sorry for posting same message again.


I am able to create EXPLICIT and IMPLICIT transfer syntax DICOM Files with createvaluefromtempfile function.

But when i try to create DICOM File with JPEGLOSSLESS AND JPEGLOSSY, i am getting problem in ChooseRepresentation.
ErrorMessage is Virtual Memory Exhausted

I am creating DICOM file with following parameters:
Height-1000, Width-1000, BitsAllocated-16, BitsStored-12, NumberOfFrames - 240

Any other way to create DICOM file with the help of above function for JPEGLOSSLESS and JPEGLOSSY, please let me know.

I am posting the code below:

First of all i am creating the pixel data and inserting that to Dataset
DcmElement *PixelDataElement = newDicomElement(DCM_PixelData);
DcmPixelData *dpix = OFstatic_cast(DcmPixelData *, PixelDataElement);
if(PixelDataElement != NULL)
{
dpix->createValueFromTempFile(new DcmInputFileStreamFactory((LPCTSTR)RawFilePath,0), (Uint32)_DcmDemographicInfo.Rows*_DcmDemographicInfo.Columns*_DcmDemographicInfo.SamplesPerPixel*_DcmDemographicInfo.NumberOfFrames*sizeof(USHORT), EBO_unknown);
}
_DcmDataSet->insert(PixelDataElement, OFFalse, OFFalse);

After creating Dataset, i am doing the Conversion :-

DJEncoderRegistration::registerCodecs( _DcmCompressionColorSpaceConversion,
EUC_default,
OFTrue,
OFTrue,
0,
0,
0,
OFTrue,
ESS_444,
OFFalse,
OFFalse,
0,
0,
0.0,
0.0,
0,
0,
0,
0,
OFTrue,
OFFalse,
OFFalse,
OFFalse,
OFTrue);

//Declare the Transfer syntax
E_TransferSyntax Xfer = EXS_JPEGProcess14SV1TransferSyntax;
OFCmdUnsignedInt SectionValue = 6;
OFCmdUnsignedInt PointTransform = 0;
OFBool Verbose = OFFalse;

//Get the dataset from given FileFormat
DcmDataset *Dataset = _DcmFileFormat.getDataset();
DcmXfer OriginalXfer(Dataset->getOriginalXfer());

//Check whether it is encapsulated or not
if (OriginalXfer.isEncapsulated())
{
_DcmErrorCode=DXSDCF_ORIGINALTRANSFERSYNTAXISENCAPSULATED;
_DcmErrorString = "Original Tansfer Syntax is Encapsulated.";
return S_FALSE;
}

//Set the LossLess Transfer Syntax
DcmXfer XferSyn(Xfer);
DJ_RPLossless RPLossless((int)SectionValue, (int)PointTransform);
const DcmRepresentationParameter *DcmRepParam = &RPLossless;
if ((Xfer == EXS_JPEGProcess14SV1TransferSyntax)||
(Xfer == EXS_JPEGProcess14TransferSyntax))
DcmRepParam = &RPLossless;

//chooseLosseless representation
Dataset->chooseRepresentation(Xfer, DcmRepParam);

//Converting to lossless transfer syntax from unknown transfer syntax
if (Dataset->canWriteXfer(Xfer))
{
if (Verbose)
XferSyn.getXferName();
}
else //if conversion is not proper then return error
{
XferSyn.getXferName();
_DcmErrorCode=DXSDCF_CANWRITETRANSFERSYNTAXFAILED;
_DcmErrorString = "Can Write Transfer Syntax failed.";
return S_FALSE;
}

//Getting all Meta Info
DcmItem *MetaInfoHeader = _DcmFileFormat.getMetaInfo();
if (MetaInfoHeader)
{
delete MetaInfoHeader->remove(DCM_MediaStorageSOPClassUID);
delete MetaInfoHeader->remove(DCM_MediaStorageSOPInstanceUID);
}

//Load Memory
_DcmFileFormat.loadAllDataIntoMemory();

//Save the Dicom File
_DcmStatus = _DcmFileFormat.saveFile((const char*)DcmFilePath, Xfer);
if(_DcmStatus.bad())
{
_DcmErrorCode=DXSDCF_ERRORINSAVINGJPEGLOSSLESSDICOMFILE;
_DcmErrorString = _DcmStatus.text();
return S_FALSE;
}

Help me if i am doing anything wrong here.
Thanks in advance.

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

#2 Post by Marco Eichelberg »

I cannot see any obvious problem in your source code. Try a debugger to find out where the "virtual memory exhausted" error is generated. This might very well be a bug in DCMTK.

retarder
Posts: 26
Joined: Fri, 2010-11-19, 16:23
Location: Germany
Contact:

Compression problem

#3 Post by retarder »

Hi,
I use the createValueFromTempFile() from DCMTK 3.5.5 on Windows 7. If I use it without compression it works for big datasets. But if I use the compression example from the helpfile, the compression works only for small pixeldata (uncompressed 100 MB). If I use it with a larger dataset (420 MB) the status from

Code: Select all

status = fileformat.saveFile(stringPointerFilepath, EXS_JPEGProcess14SV1TransferSyntax);
returns with status = 13 ("Pixel represantation not found").

Is it perhaps a problem in DCMTK or have I to consider something which is not mentioned in the example code?
Thanks in advance.

Post Reply

Who is online

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