/// <summary> /// Creates a <see cref="SegFrameImageGraphic"/> and adds the graphic to the given <see cref="IPresentationImage"/> /// </summary> /// <param name="presentationImage">The image to add the graphic to</param> /// <param name="rows">Number of rows in the new graphic</param> /// <param name="columns">Number of columns in the new graphic</param> /// <param name="xLocation">X coordinate of the graphic's origin</param> /// <param name="yLocation">Y coordinate of the graphic's origin</param> /// <param name="color">Color of the new graphic</param> /// <param name="frameIndex">Image frame index</param> /// <param name="label">Graphic's label</param> /// <param name="description">Graphic's description</param> /// <param name="segPixelData">8-bit pixel data of the segmentation overlay</param> /// <param name="segmentationDocumentReference">Reference to the Segmentation document this graphic is created for</param> /// <returns></returns> public static SegFrameImageGraphic AddSegFrameImageGraphicToPresentationImage( IPresentationImage presentationImage, int rows, int columns, float xLocation, float yLocation, Color color, int frameIndex, string label, string description, byte[] segPixelData, SegmentationDocumentReference segmentationDocumentReference) { // TODO VK: use IApplicationGraphicsProvider here!!! var overlayGraphicsProvider = presentationImage as IOverlayGraphicsProvider; if (overlayGraphicsProvider == null) { return(null); } var segFrameImageGraphic = new SegFrameImageGraphic(rows, columns, xLocation, yLocation, color, frameIndex, -1, label, description, segPixelData, segmentationDocumentReference); segFrameImageGraphic.Alpha = Seg.DefaultOpacity; var sopProvider = presentationImage as IImageSopProvider; if (sopProvider != null) { segFrameImageGraphic.ImageSopInstanceUid = sopProvider.Sop.SopInstanceUid; segFrameImageGraphic.ImageFrameNumber = sopProvider.Frame.FrameNumber; segFrameImageGraphic.ImageNumber = sopProvider.ImageSop.InstanceNumber; } overlayGraphicsProvider.OverlayGraphics.Add(segFrameImageGraphic); return(segFrameImageGraphic); }
public SegFrameImageGraphic(int rows, int columns, float xLocation, float yLocation, Color color, int frameIndex, int index, string label, string description, byte[] pixelData, SegmentationDocumentReference segmentationDocumentReference) { Platform.CheckPositive(rows, "rows"); Platform.CheckPositive(columns, "columns"); Platform.CheckNonNegative(frameIndex, "frameIndex"); _index = index; _frameIndex = frameIndex; Label = string.IsNullOrEmpty(label) ? string.Empty : label; Description = string.IsNullOrEmpty(description) ? string.Empty : description; SegmentationDocumentReference = segmentationDocumentReference; // new empty pixel buffer if (pixelData == null) { pixelData = MemoryManager.Allocate <byte>(rows * columns); } _overlayGraphic = new GrayscaleImageGraphic( rows, columns, // the reported overlay dimensions 8, // bits allocated is always 8 8, // overlays always have bit depth of 1, but we upconverted the data 7, // the high bit is now 7 after upconverting false, false, // overlays aren't signed and don't get inverted 1, 0, // overlays have no rescale pixelData); // the upconverted overlay data _overlayGraphic.SpatialTransform.TranslationX = xLocation; _overlayGraphic.SpatialTransform.TranslationY = yLocation; Color = color; Graphics.Add(_overlayGraphic); }
public SegFrameImageGraphic( int rows, int columns, Color color, int frameIndex, int index, string label, string description, byte[] pixelData, SegmentationDocumentReference segmentationDocumentReference) : this( rows, columns, 0, 0, color, frameIndex, index, label, description, pixelData, segmentationDocumentReference) { }