问题
I am looking to use JavaScript to extract and then display the image data from a DICOM file. I was wondering if anyone knew of any frameworks or tools to help me go about doing this. Thanks in advance.
回答1:
A dicom file is basically a binary file that can be parsed, as far as I'm concerned there is not a framework available that can do that. However you can make use of some HTML5 features & JQuery
http://timc.idv.tw/html5-file-upload/
Then you can use the readAsBinaryString function to retrieve the Dicom data and make a parser to parse it. However that last part might be some trouble since you'll have to implement the whole dicom specification.
Then you could get the PixelData (7FE0,0010) and display them on a <canvas>. Only problem here might be that dicom files are quite big of a size. So I'm not sure how fast it's going to be.
As stated by Nico in the comments you might need to do a conversion on the PixelData too, because the browser not always understands the bytecode that is in it (this is certainly the case where you use for example CT-datasets)
回答2:
I think 'HTML5' is the best solution. Canvas, FileAPI(readAsArrayBuffer), TypedArray make it possible to display the DICOM Image precisely.
Try the following in Javascript. 1. Create 'FileReader' object. 2. Call 'readAsArrayBuffer' method which can read the binary array. 3. Create 'Uint8Array 'object and parse the DICOM header. 4. Create image data object by using canvas method 'createImageData' for displaying binary image. 5. Set Pixel Data Attribute (7FE0,0010) to image data object. 6. Call 'putImageData', and you can display DICOM Image in canvas.
I'm sorry for my poor English... Good luck!
回答3:
For the library, you could use this: https://github.com/chafey/dicomParser
回答4:
I've been looking into this problem as well.
The solution (IMHO) would be to have a library that can extract the individual data items from the file. The DICOM standard is quite specific about how each type of variable is defined, and that information is given in each data item within the DICOM file.
So, the method that I suggest (and am currently working on) involves:
1) readAsArrayBuffer
2) Read in header bytes (DICM)...
3) Read in the different tags (keeping the ones that you want)
4) Read the pixel data (7FE0, 0010) into an array
5) Create a colour map (so you can display the images nicely) - think of the CT window/level
6) Generate an image using the color map values for the different pixel values in the array.
7) Draw the array on the canvas.
A.
回答5:
Please disregard if you want a totally javascript solution but you can use a jQuery async call to run executables from the dicom toolkit (dcmtk: https://dicom.offis.de/dcmtk.php.en) on the server side. I've used several of the binaries to convert image data to a .png file, and also used them to transform the dicom file into an xml file. From there, just either display the image or parse through the xml file on the client side.
来源:https://stackoverflow.com/questions/4093378/using-javascript-to-extract-display-dicom-image-data