how to replace pixel data on same dicom file using pydicom to read it again with any dicom viewer?

。_饼干妹妹 提交于 2019-12-03 17:19:10

The code looks OK. But, you are not overwriting original file.

You load the file with:

filename = get_testdata_files('MR_small.dcm')[0]
ds = pydicom.dcmread(filename)

where original file name is "MR_small.dcm".

Then you save the file with:

ds.save_as("after.dcm")

where destination file name is different. That means, original file is still unchanged.

You should either load "after.dcm" in your DICOM viewer to test

OR

You should overwrite the file (pydicom.filewriter.dcmwrite) while saving it.


Not a part of your problem, but if you are creating copy of original image with change in pixel data, it is recommended that you also modify instance specific information in dataset like InstanceNumber (0020,0013), SOPInstanceUID (0008,0018) etc.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!