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 
Return to the default flat view Create a new topic Submit Reply
Re: Transferring image pixel values to a DICOM file [message #76976] Wed, 20 July 2011 07:52 Go to previous message
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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
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: Fri Oct 10 13:59:51 PDT 2025

Total time taken to generate the page: 1.35666 seconds