dcmjs-org / dcmjs

Javascript implementation of DICOM manipulation
https://dcmjs.netlify.com/
MIT License
298 stars 112 forks source link

Export image as DICOM file #250

Closed muhammedmokbel closed 2 years ago

muhammedmokbel commented 2 years ago

i would like to export image in dicom file and i already used some code base in dcmjs examples to help me to create dicom file in right way

as mentioned here : https://github.com/dcmjs-org/dcmjs/blob/add-commander/examples/nodejs/generate.js

i found code base to generate dicom file and convert this file to blob after i set my pixeldata in dataset

dataset.PixelData = dataBuffer.buffer; const newblob = Dcmjs.data.datasetToBlob(dataset) const zip = new JSZIP() zip.file('image.dcm', newblob) `zip.generateAsync({ type: 'blob' }) .then(res => { saveAs(res, "newfile.zip", true) console.log(res)

  })`

that's all work fine with me but when I test the zip file on microdicom the image doesn't appear

test
muhammedmokbel commented 2 years ago

I already solved the problem but not totally the problem was that my Pixel data in uint8Array format but when convert it to int16Array the pixel data appear but in wrong way like this

test2
muhammedmokbel commented 2 years ago

when I try to reconstruct dicom file and adjust bit allocated and bit stored the image become more clear but the contrast is too high

test3
pieper commented 2 years ago

Looks like you are close - maybe you just need to adjust the window center/width to match your data range.

https://github.com/dcmjs-org/dcmjs/blob/add-commander/examples/nodejs/generate.js#L83-L84

muhammedmokbel commented 2 years ago

@pieper thank you so much for respond