comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Transferring image pixel values to a DICOM file
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Transferring image pixel values to a DICOM file [message #76976] Wed, 20 July 2011 07:52
Vivek is currently offline  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 Go to previous message
dplatten is currently offline  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 Go to previous message
Vivek is currently offline  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 Go to previous message
Vivek is currently offline  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
Re: Transferring image pixel values to a DICOM file [message #76995 is a reply to message #76990] Tue, 19 July 2011 01:11 Go to previous message
dplatten is currently offline  dplatten
Messages: 32
Registered: December 2007
Member
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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: multiple plots of different size on same page
Next Topic: Shell startup file not recognized in IDL 8.0 Workbench

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 17:12:09 PDT 2025

Total time taken to generate the page: 0.00570 seconds