Sending image from memory

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
vcslick
Posts: 8
Joined: Thu, 2006-01-26, 23:04

Sending image from memory

#1 Post by vcslick »

Hi,

Is it possible to compress the image in memory the image object? In dcmcjpeg function where does the actual compression take place? Is it possible to save the file object to memory as opposed to directly to disk via saveFile()?

What methods should I use?

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

#2 Post by Jörg Riesmeier »

First of all, I would suggest that you read the relevant part of the documentation. The call to chooseRepresentation() does the trick.

vcslick
Posts: 8
Joined: Thu, 2006-01-26, 23:04

#3 Post by vcslick »

The chooseRepresentation() function did do the compression but the problem that I find is that the transfer syntax is not getting in the dicom dataset itself until it is directly saved into file.

I tested with this code.

Code: Select all

dataset->chooseRepresentation(opt_oxfer, rp);
DcmXfer original_xfer2(dataset->getOriginalXfer());

if (original_xfer2.isNotEncapsulated())
	  printf("The conversion did not happen.\n");
else if (original_xfer2.isEncapsulated())
	  printf("Compression was successful.\n");
The output always comes out to be "The conversion did not happen."

How can I write the transfer syntax immediately after the image is compressed without saving into a file?

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 »

The transfer syntax is never stored in the dataset but in the file meta header. The method getOriginalXfer() always returns the original transfer syntax as the name indicates.

So, what is the background of your question?

vcslick
Posts: 8
Joined: Thu, 2006-01-26, 23:04

#5 Post by vcslick »

Hi Jorg,

Thanks for your response. In general, I'd like to just compress the DcmFileFormat object in memory, then immediately transfer the object.

I find that if I load the uncompressed file, run the compression routine, save the file, then reload it, yes it is then interpreted as a compressed image. I check for this condition with the following code:

Code: Select all

DcmXfer original_xfer2(dataset->getOriginalXfer()); 
if (original_xfer2.isNotEncapsulated()) 
     printf("The conversion did not happen.\n"); 
else if (original_xfer2.isEncapsulated()) 
     printf("Compression was successful.\n");
It seems that the isNotEncapsulated() function returns true after calling chooseRepresentation(), however if I save this same DcmFileFormat object to disk, reload it, and call isNotEncapsulated(), it does then return that it is compressed.

I'm wondering, what must I do in the dataset object after calling chooseRepresentation() for the rest of my routines to interpret the object as compressed?

Thanks

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

#6 Post by Jörg Riesmeier »

You could either evaluate the status code that is returned by chooseRepresentation() or call hasRepresentation() afterwards.

Post Reply

Who is online

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