Re: Transferring image pixel values to a DICOM file [message #76976] |
Wed, 20 July 2011 07:52 |
Vivek
Messages: 6 Registered: July 2011
|
Junior Member |
|
|
On Jul 20, 6:37 am, David Platten <dplat...@gmail.com> wrote:
> Hi Vivek,
>
> I used to use another method to create computed tomography DICOM files containing my own image data. I took an existing DICOM image, opened it, and then wrote my new image data over the existing image data in the file, and then saved the file. It was a nasty way to do it, but it worked. The CT images I was working on always had 512x512 pixels. An example of the code is below. There must be a more elegant way of doing this!
>
> Regards,
>
> David
>
> PRO modifyDICOM
>
> ; create an array to hold the generated image
> x_dim = 512
> y_dim = 512
> new_data = INTARR(x_dim,y_dim)
> new_data[*,*] = 0
>
> ; generate some test data to write to the image
> ; a diagonal cross
> FOR x = 0, (x_dim-1) DO BEGIN
> new_data[x,x] = 1000
> new_data[(x_dim-1)-x,x] = 1000
> ENDFOR
>
> ; Or you could load in a tif file with your image data:
> ;image_array = read_tiff('c:\TEMP\StraightEdgeReallyBlurred.tif', channels=1)
> ;new_data = fix(image_array)
>
> ; Open an existing DICOM file to modify. This must have the
> ; same pixel dimensions as the one you want to create.
> dicomFile = DIALOG_PICKFILE(/MUST_EXIST)
>
> ; open the file for writing
> OPENU, dcmfile, dicomFile, /GET_LUN, /Append
> POINT_LUN, -dcmfile, a
>
> ;position file pointer 512*512 from end of file
> POINT_LUN, dcmfile, a-(512l*512*2)
>
> ; replace the pixel data with the generated data
> WRITEU, dcmfile, new_data
>
> ; close the file and free the lun
> CLOSE, dcmfile
> FREE_LUN, dcmfile
> END
Hi David,
I managed to get around with my issues thankfully :) But thanks for
the suggestion. I shall keep this in mind as well.
Regards,
Vivek
|
|
|
Re: Transferring image pixel values to a DICOM file [message #76978 is a reply to message #76976] |
Wed, 20 July 2011 03:37  |
dplatten
Messages: 32 Registered: December 2007
|
Member |
|
|
Hi Vivek,
I used to use another method to create computed tomography DICOM files containing my own image data. I took an existing DICOM image, opened it, and then wrote my new image data over the existing image data in the file, and then saved the file. It was a nasty way to do it, but it worked. The CT images I was working on always had 512x512 pixels. An example of the code is below. There must be a more elegant way of doing this!
Regards,
David
PRO modifyDICOM
; create an array to hold the generated image
x_dim = 512
y_dim = 512
new_data = INTARR(x_dim,y_dim)
new_data[*,*] = 0
; generate some test data to write to the image
; a diagonal cross
FOR x = 0, (x_dim-1) DO BEGIN
new_data[x,x] = 1000
new_data[(x_dim-1)-x,x] = 1000
ENDFOR
; Or you could load in a tif file with your image data:
;image_array = read_tiff('c:\TEMP\StraightEdgeReallyBlurred.tif', channels=1)
;new_data = fix(image_array)
; Open an existing DICOM file to modify. This must have the
; same pixel dimensions as the one you want to create.
dicomFile = DIALOG_PICKFILE(/MUST_EXIST)
; open the file for writing
OPENU, dcmfile, dicomFile, /GET_LUN, /Append
POINT_LUN, -dcmfile, a
;position file pointer 512*512 from end of file
POINT_LUN, dcmfile, a-(512l*512*2)
; replace the pixel data with the generated data
WRITEU, dcmfile, new_data
; close the file and free the lun
CLOSE, dcmfile
FREE_LUN, dcmfile
END
|
|
|
Re: Transferring image pixel values to a DICOM file [message #76989 is a reply to message #76978] |
Tue, 19 July 2011 07:18  |
Vivek
Messages: 6 Registered: July 2011
|
Junior Member |
|
|
On Jul 19, 10:06 am, Vivek <vivek.rajshek...@gmail.com> wrote:
> On Jul 19, 4:11 am, David Platten <dplat...@gmail.com> wrote:
>
>> Dear Vivek,
>
>> I use Bhautik Joshi's dicom_writer.pro to produce DICOM images that contain my created test data. You may find it useful - it can be downloaded here:http://cow.mooh.org/dicom_writer.pro
>
>> Regards,
>
>> David
>
> Hello David,
>
> I have seen this before, but as a part of my work, I have to do this
> manually. I was probably misleading when I stated my goal I suppose. I
> need to know how to transfer images/pixel values to DICOM files. Any
> ideas regarding this?
>
> Thanks for the suggestion though :)
>
> Regards,
>
> Vivek
I am trying to use inbuilt IDL functions to do this, the IDLffDicomEx
module to be precise.
|
|
|
Re: Transferring image pixel values to a DICOM file [message #76990 is a reply to message #76989] |
Tue, 19 July 2011 07:06  |
Vivek
Messages: 6 Registered: July 2011
|
Junior Member |
|
|
On Jul 19, 4:11 am, David Platten <dplat...@gmail.com> wrote:
> Dear Vivek,
>
> I use Bhautik Joshi's dicom_writer.pro to produce DICOM images that contain my created test data. You may find it useful - it can be downloaded here:http://cow.mooh.org/dicom_writer.pro
>
> Regards,
>
> David
Hello David,
I have seen this before, but as a part of my work, I have to do this
manually. I was probably misleading when I stated my goal I suppose. I
need to know how to transfer images/pixel values to DICOM files. Any
ideas regarding this?
Thanks for the suggestion though :)
Regards,
Vivek
|
|
|
|