DICOM @ OFFIS

Discussion Forum for OFFIS DICOM Tools - For registration, send email with desired user name to the OFFIS DICOM team
It is currently Sat, 2017-06-24, 20:12

All times are UTC + 1 hour




Post new topic Reply to topic  [ 37 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: convert jpg to dicom c++
PostPosted: Mon, 2012-02-27, 10:07 
Offline

Joined: Sun, 2012-02-26, 15:12
Posts: 46
Location: Egypt
Hi,
I'm writing my own code to convert jpg to dicom using c++ with DCMTK.Then I view the dicom image using ezDicom tool. I can view the image but the colors of the dicom image is grades of orange and black that is not the same colors of my orginal jpg image.
There is another problem that is the transfer syntax of the converted dicom image is "Transfer Syntax UID=1.2.840.10008.1.2.4.50", so I can't transfer it to PACS using storscu.
But if i convert BMP image there is no any problem in convertion or transferring. Can anyone help me?. The following is my code of conversion:


Image2Dcm i2d;
I2DOutputPlug *outPlug = new I2DOutputPlugSC();
I2DImgSource *inputPlug = new I2DJpegSource();
E_TransferSyntax writeXfer;
inputPlug->setImageFile(jpgFile);
DcmDataset *dataset = NULL;
OFCondition result = i2d.convert(inputPlug, outPlug, dataset, writeXfer);

// Saving output DICOM image
if (result.good())
{
dataset->putAndInsertString(DCM_PhotometricInterpretation,"RGB");

DcmFileFormat dcmff(dataset);
result = dcmff.saveFile(dcmFile, writeXfer);
}


Top
 Profile  
 
 Post subject:
PostPosted: Mon, 2012-02-27, 10:25 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1821
Location: Oldenburg, Germany
Are you sure that your JPEG image uses RGB? What does img2dcm produce for this particular image?

Quote:
There is another problem that is the transfer syntax of the converted dicom image is "Transfer Syntax UID=1.2.840.10008.1.2.4.50", so I can't transfer it to PACS using storscu.

Of course, you can. This is at least true for the sender side (storescu). What about using option --propose-jpeg8? Using dcmsend would be easier, but this tool requires the latest DCMTK snapshot.


Top
 Profile  
 
 Post subject: convert JPEG to DICOM
PostPosted: Mon, 2012-02-27, 10:39 
Offline

Joined: Sun, 2012-02-26, 15:12
Posts: 46
Location: Egypt
J. Riesmeier wrote:
Are you sure that your JPEG image uses RGB? What does img2dcm produce for this particular image?

Quote:
There is another problem that is the transfer syntax of the converted dicom image is "Transfer Syntax UID=1.2.840.10008.1.2.4.50", so I can't transfer it to PACS using storscu.

Of course, you can. This is at least true for the sender side (storescu). What about using option --propose-jpeg8? Using dcmsend would be easier, but this tool requires the latest DCMTK snapshot.


sorry for beginnig questions. but how to ensure that my image uses RGB.
i used img2dcm tool and the output is the same as my code. And the
Photometric Interpretation=YBRFULL422.


Top
 Profile  
 
 Post subject:
PostPosted: Mon, 2012-02-27, 10:58 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1821
Location: Oldenburg, Germany
As far as I know, the img2dcm tool (and the underlying class library) does not convert the color model of the input image. It just feeds the JPEG stream into a DICOM image (and sets the header fields appropriately). Also, JPEG images with RGB color model are not that usual because the compression ratio is not as good as for the YCbCr models.


Top
 Profile  
 
 Post subject: convert JPEG to DICOM
PostPosted: Mon, 2012-02-27, 11:04 
Offline

Joined: Sun, 2012-02-26, 15:12
Posts: 46
Location: Egypt
J. Riesmeier wrote:
As far as I know, the img2dcm tool (and the underlying class library) does not convert the color model of the input image. It just feeds the JPEG stream into a DICOM image (and sets the header fields appropriately). Also, JPEG images with RGB color model are not that usual because the compression ratio is not as good as for the YCbCr models.



When I convert BMP image there is no any problem as i mentioned before. So what is the solution, how can i convert my jpeg image to dicom with same colors?!!!


Top
 Profile  
 
 Post subject:
PostPosted: Mon, 2012-02-27, 11:15 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1821
Location: Oldenburg, Germany
Obviously, one solution would be to remove the following line from your code:

Code:
dataset->putAndInsertString(DCM_PhotometricInterpretation,"RGB");


Top
 Profile  
 
 Post subject: convert JPEG to DICOM
PostPosted: Mon, 2012-02-27, 11:48 
Offline

Joined: Sun, 2012-02-26, 15:12
Posts: 46
Location: Egypt
[quote="J. Riesmeier"]Obviously, one solution would be to remove the following line from your code:

[code]dataset->putAndInsertString(DCM_PhotometricInterpretation,"RGB");[/code][/quote]

I removed this line but the effect is the same.


Top
 Profile  
 
 Post subject:
PostPosted: Mon, 2012-02-27, 11:49 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1821
Location: Oldenburg, Germany
But the DICOM output is now identical to img2dcm? Maybe, your viewer is wrong?


Top
 Profile  
 
 Post subject: convert JPEG to DICOM
PostPosted: Mon, 2012-02-27, 11:51 
Offline

Joined: Sun, 2012-02-26, 15:12
Posts: 46
Location: Egypt
[quote="J. Riesmeier"]But the DICOM output is now identical to img2dcm? Maybe, your viewer is wrong?[/quote]

yes, it is identical. I use ezDicom viewer.


Top
 Profile  
 
 Post subject:
PostPosted: Mon, 2012-02-27, 11:52 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1821
Location: Oldenburg, Germany
What about trying another DICOM viewer in order to see whether ezDicom is correct or wrong?


Top
 Profile  
 
 Post subject: convert JPEG to DICOM
PostPosted: Mon, 2012-02-27, 11:54 
Offline

Joined: Sun, 2012-02-26, 15:12
Posts: 46
Location: Egypt
[quote="J. Riesmeier"]What about trying another DICOM viewer in order to see whether ezDicom is correct or wrong?[/quote]

Can you suggest any viewer?


Top
 Profile  
 
 Post subject:
PostPosted: Mon, 2012-02-27, 11:56 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1821
Location: Oldenburg, Germany
If you need a viewer for the Windows OS, you could e.g. try synedra View Personal.


Top
 Profile  
 
 Post subject:
PostPosted: Mon, 2012-02-27, 12:49 
Offline

Joined: Sun, 2012-02-26, 15:12
Posts: 46
Location: Egypt
J. Riesmeier wrote:
If you need a viewer for the Windows OS, you could e.g. try synedra View Personal.


I tried this viewer. But there is a problem in color also. But when I used its converter the result is correct and ezDICOM can view the image correctly. When i examined the tags in ezDICOM in case of my converted image using my code or img2dcm i found:
TransferSyntaxUID =JPEGBaseline
PhotometricInterpretation=YBRFULL422
Pixel Data=0

But in case of the converted image from synedra viewer (which is correct as the output from converting BMP image) i found:
TransferSyntaxUID =LittleEndianExplicit
PhotometricInterpretation=RGB
Pixel Data=3888000


Top
 Profile  
 
 Post subject:
PostPosted: Mon, 2012-02-27, 16:34 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1821
Location: Oldenburg, Germany
Sorry, but I don't get what you intend to say in your last posting. Could you please describe again (with other words or in more detail) what you did to create the DICOM image, what the textual dump is (group 0028 and pixel data) and which viewer shows what result.


Top
 Profile  
 
 Post subject: convert JPEG to DICOM
PostPosted: Mon, 2012-02-27, 16:57 
Offline

Joined: Sun, 2012-02-26, 15:12
Posts: 46
Location: Egypt
J. Riesmeier wrote:
Sorry, but I don't get what you intend to say in your last posting. Could you please describe again (with other word or in more detail) what you did to create the DICOM image, what the textual dump is (group 0028 and pixel data) and which viewer shows what result.


I used the synedra viewer to view the dicom image i generated from my code and the colors of this image were not correct as happend with ezDICOM viewer. So the problem is not in the viewer.

I converted the jpeg image with the synedra converter and the colors of the dicom image were the same of the original image.

Now I have two dicom images one from my code and one from synedra converter. I took these two images and view them in ezDICOM viewer and display their meta data i found the following differences:

in case of my converted image i found:
TransferSyntaxUID =JPEGBaseline
PhotometricInterpretation=YBRFULL422
Pixel Data=0

But in case of the converted image from synedra converter i found:
TransferSyntaxUID =LittleEndianExplicit
PhotometricInterpretation=RGB
Pixel Data=3888000

Data in group 0028 are the same in the two cases:
0028,0002,Samples Per Pixel=3
0028,0006,Planar Configuration=0
0028,0010,Rows=900
0028,0011,Columns=1440
0028,0100,Bits Allocated=8
0028,0101,Bits Stored=8
0028,0102,High Bit=7
0028,0103,Pixel Representation=0
0028,2110,?=12592
0028,2114,?=ISO.10918.1

so why these differences?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 37 posts ]  Go to page 1, 2, 3  Next

All times are UTC + 1 hour


Who is online

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


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group