[英]How can I create a DICOM file from a existing opencv Mat image using dcmtk?
I am new to DICOM and dcmtk.我是 DICOM 和 dcmtk 的新手。
I use dcmtk to read a DICOM image and convert it to a opencv Mat.我使用 dcmtk 读取 DICOM 图像并将其转换为 opencv Mat。 Then do some processing by opencv. Now I want to save the processed image back to DICOM image.
然后通过opencv做一些处理。现在我想将处理后的图像保存回DICOM图像。 But I don't know how to create a DICOM file from a opencv Mat (I only need the pixel data).
但我不知道如何从 opencv Mat 创建 DICOM 文件(我只需要像素数据)。
I just change the pixel values to do some denoising.我只是改变像素值来做一些去噪。 Bit depth, resolution and other information stay the same.
位深度、分辨率和其他信息保持不变。
I am using simple X-Ray images of SMT or other objects in DICOM format.我正在使用 DICOM 格式的 SMT 或其他对象的简单 X 射线图像。
Could anyone tell me how to do it with opencv, c++ and dcmtk.谁能告诉我如何使用 opencv、c++ 和 dcmtk 来做到这一点。
My goal is to Generate a image(DICOM file) with the same pixel data as existing Mat in the specified directory.我的目标是生成具有与指定目录中现有 Mat 相同像素数据的图像(DICOM 文件)。 If possible, please show me some code.
如果可能的话,请给我一些代码。
DICOM has the concept of IODs (Information Object Definitions) which is a bit hard to grasp for beginners. DICOM 有 IOD(信息 Object 定义)的概念,对于初学者来说有点难以掌握。 With your comments that everything about the pixel format remains constant, and you are just improving the image quality, I would propose that you copy the original image and save a modified version of it back (to a different filename) rather than creating a new image from scratch.
根据您的评论,关于像素格式的一切都保持不变,而您只是在提高图像质量,我建议您复制原始图像并将其修改后的版本保存回去(以不同的文件名),而不是创建新图像从头开始。
To conform to DICOM, you will have to change a few more attributes in the modified copy of your original image:为了符合 DICOM,您必须在原始图像的修改副本中更改更多属性:
Ideally, you would also:理想情况下,您还将:
Sorry for being too lazy to write the code for you.抱歉懒得给你写代码了。 But in the sources of the Dcmtk samples you will find a plethora of references that show how to do these modifications.
但在 Dcmtk 示例的源代码中,您会发现大量参考资料,这些参考资料展示了如何进行这些修改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.