Edit and Change Settings of DICOM Annotations

In the “Add and Save DICOM Annotations” blog, we walked through a few of the methods LEADTOOLS offers to manipulate DICOM graphic and text annotations. In this post, we will show how to set up DICOM image flags, edit and change the settings used to create DICOM annotations, and set up the presentation state identification.

DICOM Image Flags

To begin, we need to breakdown the following arguments used in GetImage to prepare the image for annotations:

private static void AddAnnotationAndSave(string imageFile)
{
   DicomElement element = imageDs.FindFirstElement(null, DicomTag.PixelData, true);
   var image = imageDs.GetImage(element, 0, 0, RasterByteOrder.Gray,
         DicomGetImageFlags.AutoApplyModalityLut |
         DicomGetImageFlags.AutoApplyVoiLut |
         DicomGetImageFlags.AutoScaleModalityLut |
         DicomGetImageFlags.AutoScaleVoiLut |
         DicomGetImageFlags.AutoDetectInvalidRleCompression
         );
}

The first couple of arguments are standard: the element we are using (DicomElement), the index of the element (0), the bits-per-pixel (0), and the RasterByteOrder  (Gray). We will now briefly describe what each of the DicomGetImageFlags arguments do to help shape our image.

  • AutoApplyModalityLut – This method will automatically apply the “Modality LUT” when loading the image.
  • AutoApplyVoiLut – This method will automatically apply the “VOI LUT” when loading the image.
  • AutScaleModalityLut – This method will scale the resulting pixel data to fit within the range of 0 to 2^BitsPerPixel-1 if any of the values would exceed that range.
  • AutoScaleVoiLut – Only used in conjunction with AutoScaleModalityLut. This method will rescale the VOI LUT to match the rescale that was performed by AutoScaleModalityLut.
  • AutoDetectInvalidRleCompression – This method will automatically detect invalid RLE compression.

DICOM Annotation Settings

In the following ruler annotation code, we can see how it was setup and which settings were used:


static void Main(string[] args)
{
  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);
}

  • ruler.Points.Add is called twice for each end of the ruler object that is going to be made. We are using LeadPointD.Create to get that point, with its arguments being the x and y coordinate for said point. These numbers can be changed to relocate the location that the ruler will be made into a line between both points.
  • ruler.Stroke.Stroke is setting the stroke property for our newly created ruler object. It uses the AnnSolidColorBrush.Create to set the strokes of the ruler to the color red; as that is the argument passed on to the create method. We can just as easily swap out the word “red” to “blue” or “yellow” and the color will change accordingly.
  • ruler.Stroke.StrokeThickness is setting the thickness of the strokes we have made for our object. This is set by calling LeadLengthD.Create and inputting the desired amount. In the previous example we used “2” as our size but you could use other sizes like “3” or “4”.

In the above example, we used AnnPolyRulerObject as the annotation object. With the LEADTOOLS Annotations Engine, there are many other options available such as AnnPointObject, AnnRedactionObject, and AnnRubberStampObject.

Presentation State Identification

The last bit of code that we are going to analyze will be our PresentationStateIdentificationModule:


{
  PresentationStateIdentification = new PresentationStateIdentificationModule
  {
   ContentCreatorName = "",
   ContentDescription = "",
   ContentLabel = "",
   CreationDate = new DicomDateValue(DateTime.Now),
   CreationTime = new DicomTimeValue(DateTime.Now),
   InstanceNumber = 1
  }
}

ContentCreatorName, ContentDescription, and ContentLabel help describe who created the content, why it was created, and what it is labeled as.

CreationDate and CreationTime both use DicomDateValue and DicomTimeValue respectively to register the current date and time of creation. And finally, the InstanceNumber gets or sets the instance number for future identification.

This is just a small fraction of just how customizable things can be using LEADTOOLS DICOM Annotations… now just imagine all the other features we offer!

Download LEADTOOLS and Stay Tuned for More!

Better yet, don’t imagine. Download our FREE 60-day evaluation SDK to test all of our features and actually program with LEADTOOLS and receive our fully-sourced demos.

Not sure where to start? Schedule a walk-through with our support team to check out our many features that will expedite your application development!

For pricing or licensing questions, contact our sales team via email or call us at 704-332-5532. Be sure to check out our product wizard and pricing estimator as well.

And we’re not done with DICOM Annotations just yet! We have more helpful posts coming your way, so be sure to stay tuned!

About 

This entry was posted in Annotations, Medical Imaging and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *