From: ucd puri on
Hi, I am trying to write an array in dicom format using dicomwrite as below,

a=[1 2 3; 4 5 6; 7 8 9]; % where 'a' is a greyscale image originally.
dicomwrite( a , 'im1')

but now if i read this im1 file, i get very strange values something like
[ 65535 65535 65535; 65535 65535 65535;65535 65535 65535]

Please suggest.
Thx in advance.
From: Sadik on
Hi,

If you look at the header [or the so-called metadata] of a dicom file using dicominfo, you should see a tag with name "Pixel Representation". If I remember correctly, a value of 1 says it is signed, and 0 says unsigned. When you write your dicom file, you should watch for this tag as far as I infer from your problem.

An example:

metadata = dicominfo('anyDicom.dcm'); % so that you have a sample metadata struct
metadata.PixelRepresentation = 1; % or 0, whichever you wish.
dicomwrite(myImage,'newDicom.dcm',metadata);

This is just an example. You may have to play with it. For example, you had better choose more carefully the dicom file from which you get the metadata, it should be close to that of your desired dicom.

Best.
From: ucd puri on
Dear Sadik,
Thanks a lot for your reply.

I tried to play around with PixelRepresentation, but did not help much.
I am basically having a metadata of a PET image, and i am using 'CreateMode'='copy' to write the metadata as following

dicomwrite( mydata , 'filename' , metadata , 'CreateMode', 'Copy' )

Unfortunately, it did not help. Thats why i tried to write a very simple array, as i showed previously, but i am have the same problem. The dicom file that is written has values either 0 or 65535. I really dont understand the problem.

I appreciate any help.

Best Wishes
Tanuj
From: Sadik on
Hi Tanuj,

1. What is the range of values in your image?

2. You could also try the following. You can save your image as an analyze file [that is, *.hdr] from within matlab [you can find such matlab functions on the net], and then you can open it with one of the freely available image viewers [for instance imagej] and finally, you can save your image as dicom using that image viewer.

Best.