convert jpg to dicom c++
Moderator: Moderator Team
-
- DCMTK Developer
- Posts: 2512
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
-
- Posts: 46
- Joined: Sun, 2012-02-26, 15:12
- Location: Egypt
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.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)?
-
- Posts: 46
- Joined: Sun, 2012-02-26, 15:12
- Location: Egypt
How I know if the jpeg is correct?MuhammadHemdan wrote: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.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)?
-
- Posts: 46
- Joined: Sun, 2012-02-26, 15:12
- Location: Egypt
convert JPEG to DICOM
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.MuhammadHemdan wrote:How I know if the jpeg is correct?MuhammadHemdan wrote: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.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)?
-
- DCMTK Developer
- Posts: 2512
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
-
- Posts: 46
- Joined: Sun, 2012-02-26, 15:12
- Location: Egypt
convert JPEG to DICOM
Yes the JPEG image show up correctly in a conventional image viewer.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?
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.
-
- DCMTK Developer
- Posts: 2512
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
-
- Posts: 46
- Joined: Sun, 2012-02-26, 15:12
- Location: Egypt
convert JPEG to DICOM
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.
-
- Posts: 101
- Joined: Wed, 2009-07-08, 16:06
- Location: Oldenburg, Germany
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.
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.
-
- Posts: 46
- Joined: Sun, 2012-02-26, 15:12
- Location: Egypt
convert JPEG to DICOM
Thank you so much for your interesting. I spent alot of time in this problem. Everything is well now.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.
-
- DCMTK Developer
- Posts: 2512
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
-
- DCMTK Developer
- Posts: 2512
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
-
- Posts: 46
- Joined: Sun, 2012-02-26, 15:12
- Location: Egypt
convert JPEG to DICOM
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?
-
- Posts: 46
- Joined: Sun, 2012-02-26, 15:12
- Location: Egypt
Re: convert JPEG to DICOM
I write the following code but the generated dicom image can't be viewed.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?
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
-
- DCMTK Developer
- Posts: 2512
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
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 ...
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
Who is online
Users browsing this forum: Bing [Bot] and 1 guest