convert jpg to dicom c++

All other questions regarding DCMTK

Moderator: Moderator Team

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

#16 Post by J. Riesmeier »

I also create a JPEG baseline compressed DICOM image (with YBR_FULL_422) using img2dcm and opened it with the synedra viewer: The result was as expected.

Are you sure that your input JPEG image is correct? Could you send that particular image to us by email (dicom/at/offis/dot/de)?

MuhammadHemdan
Posts: 46
Joined: Sun, 2012-02-26, 15:12
Location: Egypt

#17 Post by MuhammadHemdan »

J. Riesmeier wrote:I also create a JPEG baseline compressed DICOM image (with YBR_FULL_422) using img2dcm and opened it with the synedra viewer: The result was as expected.

Are you sure that your input JPEG image is correct? Could you send that particular image to us by email (dicom/at/offis/dot/de)?
You are right. I did this test and works well. I will see how my jpeg is saved. Thank you for your interesting. Thanks alot.

MuhammadHemdan
Posts: 46
Joined: Sun, 2012-02-26, 15:12
Location: Egypt

#18 Post by MuhammadHemdan »

MuhammadHemdan wrote:
J. Riesmeier wrote:I also create a JPEG baseline compressed DICOM image (with YBR_FULL_422) using img2dcm and opened it with the synedra viewer: The result was as expected.

Are you sure that your input JPEG image is correct? Could you send that particular image to us by email (dicom/at/offis/dot/de)?
You are right. I did this test and works well. I will see how my jpeg is saved. Thank you for your interesting. Thanks alot.
How I know if the jpeg is correct?

MuhammadHemdan
Posts: 46
Joined: Sun, 2012-02-26, 15:12
Location: Egypt

convert JPEG to DICOM

#19 Post by MuhammadHemdan »

MuhammadHemdan wrote:
MuhammadHemdan wrote:
J. Riesmeier wrote:I also create a JPEG baseline compressed DICOM image (with YBR_FULL_422) using img2dcm and opened it with the synedra viewer: The result was as expected.

Are you sure that your input JPEG image is correct? Could you send that particular image to us by email (dicom/at/offis/dot/de)?
You are right. I did this test and works well. I will see how my jpeg is saved. Thank you for your interesting. Thanks alot.
How I know if the jpeg is correct?
Sorry for repeating the question, But how can i know if the jpeg image is correct or not? I can't send the image because of Confidentiality.

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

#20 Post by J. Riesmeier »

Does the JPEG image show up correctly in a conventional image viewer?

What do you mean by "You are right. I did this test and works well." in your previous posting?

MuhammadHemdan
Posts: 46
Joined: Sun, 2012-02-26, 15:12
Location: Egypt

convert JPEG to DICOM

#21 Post by MuhammadHemdan »

J. Riesmeier wrote:Does the JPEG image show up correctly in a conventional image viewer?

What do you mean by "You are right. I did this test and works well." in your previous posting?
Yes the JPEG image show up correctly in a conventional image viewer.

My application saves image as jpeg using jpeglib. When I convert the jpeg image out from my application to dcm the problem happens.
But if I take print screen and save the image as jpeg using Paint tool then convert it to dcm there is no any problem.

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

#22 Post by J. Riesmeier »

Maybe, you could send another problematical JPEG image to us, i.e. one without confidential information.

MuhammadHemdan
Posts: 46
Joined: Sun, 2012-02-26, 15:12
Location: Egypt

convert JPEG to DICOM

#23 Post by MuhammadHemdan »

J. Riesmeier wrote:Maybe, you could send another problematical JPEG image to us, i.e. one without confidential information.

I sent two images by e-mail. one jpeg out from my application and the other the dicom image.

omarelgazzar
Posts: 101
Joined: Wed, 2009-07-08, 16:06
Location: Oldenburg, Germany

#24 Post by omarelgazzar »

Hello,
I tried to view the images with Sante DICOM Viewer the result was fine and as expected. I compared your output DICOM image with the output of the img2dcm and they are using the same photometric interpretation color model YBR_FULL_422. So, it seems the problem is in the Synedra viewer which does not support non-RGB color model. Btw, when I dumped the image on Synedra viewer using their own dump viewer, I found the Photometric interpretation RGB which is probably the reason for the strange behaviour of the image viewing after converting from YBR_FULL_422 -> RGB. So, the output of img2dcm should be fine and can only work with viewers such as Sante which support YBR_FULL_422 color model.

MuhammadHemdan
Posts: 46
Joined: Sun, 2012-02-26, 15:12
Location: Egypt

convert JPEG to DICOM

#25 Post by MuhammadHemdan »

omarelgazzar wrote:Hello,
I tried to view the images with Sante DICOM Viewer the result was fine and as expected. I compared your output DICOM image with the output of the img2dcm and they are using the same photometric interpretation color model YBR_FULL_422. So, it seems the problem is in the Synedra viewer which does not support non-RGB color model. Btw, when I dumped the image on Synedra viewer using their own dump viewer, I found the Photometric interpretation RGB which is probably the reason for the strange behaviour of the image viewing after converting from YBR_FULL_422 -> RGB. So, the output of img2dcm should be fine and can only work with viewers such as Sante which support YBR_FULL_422 color model.
Thank you so much for your interesting. I spent alot of time in this problem. Everything is well now.

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

#26 Post by J. Riesmeier »

omarelgazzar wrote:So, it seems the problem is in the Synedra viewer which does not support non-RGB color model.
No, the Synedra viewer can display such images correctly, but for some reason not the one "MuhammadHemdan" has provided by email. This could also be a bug in img2dcm.

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

#27 Post by J. Riesmeier »

To me it seems that the input JPEG image uses RGB color space instead of YCbCr. When I decompress the JPEG-compressed DICOM image image with dcmdjpeg --conv-guess, the output looks ok.

Btw, the Synedra viewer is based on DCMTK ...

MuhammadHemdan
Posts: 46
Joined: Sun, 2012-02-26, 15:12
Location: Egypt

convert JPEG to DICOM

#28 Post by MuhammadHemdan »

J. Riesmeier wrote:To me it seems that the input JPEG image uses RGB color space instead of YCbCr. When I decompress the JPEG-compressed DICOM image image with dcmdjpeg --conv-guess, the output looks ok.

Btw, the Synedra viewer is based on DCMTK ...

How can i do this in my application using c++? is this by DJDecoderRegistration?

MuhammadHemdan
Posts: 46
Joined: Sun, 2012-02-26, 15:12
Location: Egypt

Re: convert JPEG to DICOM

#29 Post by MuhammadHemdan »

MuhammadHemdan wrote:
J. Riesmeier wrote:To me it seems that the input JPEG image uses RGB color space instead of YCbCr. When I decompress the JPEG-compressed DICOM image image with dcmdjpeg --conv-guess, the output looks ok.

Btw, the Synedra viewer is based on DCMTK ...

How can i do this in my application using c++? is this by DJDecoderRegistration?
I write the following code but the generated dicom image can't be viewed.
What is the problem? Are the parameteres of the function correct?

DJDecoderRegistration::registerCodecs(EDC_guess); // register JPEG codecs
if (dcmff.loadFile(pDICOM).good())
{
// decompress data set if compressed
dataset->chooseRepresentation(EXS_LittleEndianExplicit, NULL);

// check if everything went well
if (dataset->canWriteXfer(EXS_LittleEndianExplicit))
{
result = dcmff.saveFile(pDICOM, EXS_LittleEndianExplicit);
}
}
DJDecoderRegistration::cleanup(); // deregister JPEG codecs

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

#30 Post by J. Riesmeier »

Where do you define "dataset"? Its value should be the pointer returned by dcmff.getDataset().

Btw, the color space conversion flags are also available to dcmj2pnm ...

Code: Select all

color space conversion (compressed images only):

  +cp   --conv-photometric
          convert if YCbCr photometric interpretation (default)

  +cl   --conv-lossy
          convert YCbCr to RGB if lossy JPEG

  +cg   --conv-guess
          convert to RGB if YCbCr is guessed by library

  +cgl  --conv-guess-lossy
          convert to RGB if lossy JPEG and YCbCr is
          guessed by the underlying JPEG library

  +ca   --conv-always
          always convert YCbCr to RGB

  +cn   --conv-never
          never convert color space

Post Reply

Who is online

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