添加和保存DICOM注释

dicomnologo

添加笔记,箭头,尺寸,形状,和其他注释DICOM文件存储时是非常重要的医疗保健行业。LEADTOOLS提供了大量的方法来操作DICOM图像和文本注释

这个博客将会是多么简单的DICOM数据集以编程方式添加注解,出口注释而遵循DICOM标准通过保存到演讲状态文件,以及如何加载和显示注释和像素数据在一个图像浏览器。

要点

在下面的代码中,“AddAnnotationAndSave”方法进行如下操作:

  • 加载一个DICOM数据集和提取像素数据。
  • 创建注释容器和设置的分辨率容器mapper和容器的大小,将图像的像素坐标数据转换为使用注释坐标AnnContainerMapper转换方法。然后补充说,注释到新创建的DICOM数据集与图像从加载数据集。
  • 并将它们添加到创建样例注释AnnContainer.Children收集。然后使用包含在辅助功能DicomAnnotationsUtilities将AnnContainer DICOM注释并将它们存储在适当的标签新的DICOM数据集内将所有状态信息的介绍。
  • 表示状态输出数据集文件”。之前的扩展可以加载和注释数据提取。

代码

私有静态孔隙AddAnnotationAndSave(字符串imageFile) {/ / DicomEngine代码中只需要调用一次,然后关闭当退出应用程序DicomEngine.Startup ();/ /创建一个新的和加载image3。使用var dcm使用图像数据从它成像= new DicomDataSet ();成像。负载(imageFile DicomDataSetLoadFlags.None);/ /这集DicomElement第一个PixelData元素加载数据集的发现和获取图像DicomElement元素=成像。FindFirstElement (null, DicomTag。PixelData,真正的);var =成像图像。GetImage(元素,0,0,RasterByteOrder。灰色,DicomGetImageFlags。AutoApplyModalityLut | DicomGetImageFlags。AutoApplyVoiLut | DicomGetImageFlags。AutoScaleModalityLut | DicomGetImageFlags。AutoScaleVoiLut | DicomGetImageFlags。AutoDetectInvalidRleCompression);  //These next blocks will create the annotation objects that will be placed on the image  var rectangle = new Leadtools.Annotations.Engine.AnnRectangleObject();  rectangle.Rect = LeadRectD.Create(0, 0, 110, 100);  rectangle.Stroke.Stroke = AnnSolidColorBrush.Create("red");  var ruler = new Leadtools.Annotations.Engine.AnnPolyRulerObject();  ruler.Points.Add(LeadPointD.Create(50, 50));  ruler.Points.Add(LeadPointD.Create(170, 50));  ruler.Stroke.Stroke = AnnSolidColorBrush.Create("red");  ruler.Stroke.StrokeThickness = LeadLengthD.Create(2);  var text = new Leadtools.Annotations.Engine.AnnTextPointerObject();  text.Rect = LeadRectD.Create(170, 75, 50, 25);  text.Text = "This is a sample text.\nThis would be useful for\nleaving notes";  text.FixedPointer = false;  text.PointerPosition = LeadPointD.Create(100, 50);  annContainer.Children.Add(rectangle);  annContainer.Children.Add(ruler);  annContainer.Children.Add(text);  //This sets default information for the DicomAnnotationsUtilities/PresentationStateIdentificationModule  var dicomAnnUtils = new DicomAnnotationsUtilities  {   PresentationStateIdentification = new PresentationStateIdentificationModule   {    ContentCreatorName = "",    ContentDescription = "",    ContentLabel = "",    CreationDate = new DicomDateValue(DateTime.Now),    CreationTime = new DicomTimeValue(DateTime.Now),    InstanceNumber = 1   }  };  //This creates a new DicomDataSet to house the image with annotations and saves it out as a .pre file  //so it can be used with a dcm file of the same name. For example, if we run image2.dcm in the DicomAnnotationDemo it will  //autoload the new file, image2.pre, we create here  using var preDs = new DicomDataSet();  dicomAnnUtils.FromAnnContainerToDataSet(preDs, annContainer, imageDs, string.Empty, string.Empty);  preDs.Save(Path.ChangeExtension(imageFile, ".pre"), DicomDataSetSaveFlags.None);  //Shuts down the engine  DicomEngine.Shutdown(); }

我们称之为AddAnnotationAndSave()内的主要()的其他声明如图所示。这里我们要注意的关键点是使用正确的CDLLs Platform.LibraryPath()由于我们使用. net 6。

静态void Main (string [] args){/ /由于我们使用NET6我们要确保使用正确的CDLLS平台。LibraryPath = Path.GetDirectoryName (@ " C: \ LEADTOOLS22 \ Bin \ CDLL \ x64 \”);SetLicense ();var ImagesDir = @ " C: \ LEADTOOLS22 \ \图片资源”;var imageFile =路径。结合(ImagesDir,“日本”、“image2.dcm”);AddAnnotationAndSave (imageFile);控制台。WriteLine(“完成应用注释!”);}

试着给自己!

使用上面的代码和LEADTOOLS DICOM注释演示(中找到我们的评估SDK),您将能够看到像这样创建的注释:

dicomDemopic

想要了解更多关于DICOM注释吗?请继续关注!

我们有更多有用的帖子你关于DICOM注释,所以请继续关注!与此同时,别忘了下载我们的免费60天的评估SDK测试我们所有的特性和实际项目与LEADTOOLS甚至购买之前。

我们的支持团队总是来帮忙!通过联系我们免费技术支持即时聊天电子邮件

定价或许可问题,联系我们的销售团队通过电子邮件或给我们打电话704-332-5532。一定要看看我们产品向导价格估计量!

这一条目将发表在net,注释,医学成像和标记,,,。书签的永久链接

留下一个回复

你的电子邮件地址将不会被发表。必填字段标记*