Navigation:  I Want To... > DICOM Imaging >

Add a DICOM display shutter

Previous pageReturn to chapter overviewNext page

Use Case

You want to add a geometric display shutter on the image in a manner that conforms to DICOM Part 3.3, Section C.7.6.11.

Relevant Architecture

Image graphics
DICOM presentation state

Relevant Types

IDicomPresentationImage
DicomGraphicsPlane
GeometricShuttersGraphic
CircularShutter
PolygonalShutter
RectangularShutter

Sample Code

using System;

using System.Drawing;

using ClearCanvas.Common;

using ClearCanvas.Desktop;

using ClearCanvas.Desktop.Actions;

using ClearCanvas.ImageViewer;

using ClearCanvas.ImageViewer.BaseTools;

using ClearCanvas.ImageViewer.Graphics;

using ClearCanvas.ImageViewer.PresentationStates;

using ClearCanvas.ImageViewer.PresentationStates.Dicom;

 

// ... (other using namespace statements here)

 

namespace MyPlugin.DicomImaging

{

   [ButtonAction("apply""global-toolbars/ToolbarStandard/AddGeometricShutterTool""Apply")]

   [IconSet("apply", IconScheme.Colour, "Icons.MyToolSmall.png""Icons.MyToolMedium.png""Icons.MyToolLarge.png")]

   // ... (other action attributes here)

   [ExtensionOf(typeof (ImageViewerToolExtensionPoint))]

   public class AddGeometricShutterTool : ImageViewerTool

   {

      public void Apply()

      {

         IDicomPresentationImage image = this.SelectedPresentationImage as IDicomPresentationImage;

 

         if (image == null)

            return;

 

         // Get the base image

         ImageGraphic baseImage = image.ImageGraphic;

 

         // Get the DICOM graphics plane

         DicomGraphicsPlane dicomGraphicsPlane = DicomGraphicsPlane.GetDicomGraphicsPlane(image, true);

 

         // Create the largest possible circular shutter graphic that is still smaller than the image itself

         GeometricShuttersGraphic shutter = new GeometricShuttersGraphic(baseImage.Rows, baseImage.Columns);

         shutter.CustomShutters.Add(new CircularShutter(new Point(baseImage.Columns/2, baseImage.Rows/2), Math.Min(baseImage.Rows, baseImage.Columns)/2));

 

         // Add the shutter to the collection of available shutters on the image

         dicomGraphicsPlane.Shutters.Add(shutter);

 

         // Activate the shutter

         dicomGraphicsPlane.Shutters.Activate(shutter);

 

         // Now render

         image.Draw();

      }

   }

}

Remarks

DICOM display shutters are masks applied on the image at presentation for the purposes of suppressing certain pixels from being displayed without irreversibly modifying the image's pixel data.  The shutters can be defined as a combination of geometric shapes or as an arbitrary bitmap.

In the sample above, the tool creates a circular shutter centred on the image with a radius such that the entire circle is within the bounds of the image.

Examples in Code Base

ClearCanvas.ImageViewer.Tools.Standard.DrawShutterTool