Represents a static region of interest for the purposes of computing statistics on the contained pixels.

Roi objects are static definitions of a region of interest on a particular image. Its shape definition and the underlying pixel values are considered fixed upon construction, and hence its various properties and statistics are non-changing.

New instances of a Roi should be constructed everytime the definition of the region of interest or the underlying image pixel data has changed. The IGraphic.GetRoi method allows client code to quickly construct a new instance of a Roi based on the current definition of the graphic and the image it currently belongs to.

		public static RoiStatistics Calculate(Roi roi)
		{
			if (!(roi.PixelData is GrayscalePixelData))
				return new RoiStatistics();

			double mean = CalculateMean(
				roi.BoundingBox, 
				(GrayscalePixelData)roi.PixelData, 
				roi.ModalityLut, 
				roi.Contains);

			double stdDev = CalculateStandardDeviation(
				mean, 
				roi.BoundingBox, 
				(GrayscalePixelData)roi.PixelData, 
				roi.ModalityLut, 
				roi.Contains);

			return new RoiStatistics(mean, stdDev);
		}
Example #2
0
        /// <summary>
        /// Forces the callout to update, allowing all the analyzers to recompute and update the text content of the callout.
        /// </summary>
        /// <param name="roi">A particular region of interest information object to use when computing statistics.</param>
        /// <param name="mode">A value indicating whether or not the current region of interest is in the state of changing, and therefore whether or not analyzers should skip expensive computations.</param>
        public void Update(Roi roi, RoiAnalysisMode mode)
        {
            if (this.ImageViewer == null)
            {
                return;
            }

            StringBuilder builder = new StringBuilder();
            var           parent  = ParentGraphic;

            if (parent != null && !string.IsNullOrEmpty(parent.Name))
            {
                builder.AppendLine(parent.Name);
            }

            if (_showAnalysis && _roiAnalyzers.Count > 0 && roi != null)
            {
                try
                {
                    foreach (IRoiAnalyzer analyzer in _roiAnalyzers)
                    {
                        if (analyzer.SupportsRoi(roi))
                        {
                            var analysis = analyzer.Analyze(roi, mode);
                            if (analysis != null)
                            {
                                builder.AppendLine(analysis.SerializedAsString());
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Platform.Log(LogLevel.Error, e);
                    builder.AppendLine(SR.MessageRoiAnalysisError);
                }
            }

            base.Text = builder.ToString().Trim();
        }
Example #3
0
        public static RoiStatistics Calculate(Roi roi)
        {
            if (!(roi.PixelData is GrayscalePixelData))
            {
                return(new RoiStatistics());
            }

            double mean = CalculateMean(
                roi.BoundingBox,
                (GrayscalePixelData)roi.PixelData,
                roi.ModalityLut,
                roi.Contains);

            double stdDev = CalculateStandardDeviation(
                mean,
                roi.BoundingBox,
                (GrayscalePixelData)roi.PixelData,
                roi.ModalityLut,
                roi.Contains);

            return(new RoiStatistics(mean, stdDev));
        }
Example #4
0
		/// <summary>
		/// Forces the callout to update, allowing all the analyzers to recompute and update the text content of the callout.
		/// </summary>
		/// <param name="roi">A particular region of interest information object to use when computing statistics.</param>
		/// <param name="mode">A value indicating whether or not the current region of interest is in the state of changing, and therefore whether or not analyzers should skip expensive computations.</param>
		public void Update(Roi roi, RoiAnalysisMode mode)
		{
			if (this.ImageViewer == null)
			{
				return;
			}

			StringBuilder builder = new StringBuilder();
			RoiGraphic parent = this.ParentGraphic;
			if (parent != null && !string.IsNullOrEmpty(parent.Name))
				builder.AppendLine(parent.Name);

			if (_showAnalysis && _roiAnalyzers.Count > 0 && roi != null)
			{
				try
				{
					foreach (IRoiAnalyzer analyzer in _roiAnalyzers)
					{
						if (analyzer.SupportsRoi(roi))
						{
						    var analysis = analyzer.Analyze(roi, mode);
						    if (analysis != null)
						    {
						        builder.AppendLine(analysis.SerializedAsString());
						    }
						}
					}
				}
				catch (Exception e)
				{
					Platform.Log(LogLevel.Error, e);
					builder.AppendLine(SR.MessageRoiAnalysisError);
				}
			}

			base.Text = builder.ToString().Trim();
		}
Example #5
0
		/// <summary>
		/// Forces the callout to update, allowing all the analyzers to recompute and update the text content of the callout immediately.
		/// </summary>
		/// <param name="roi">A particular region of interest information object to use when computing statistics.</param>
		public void Update(Roi roi)
		{
			this.Update(roi, RoiAnalysisMode.Normal);
		}
Example #6
0
		private void Analyze(bool responsive)
		{
			_roi = base.Subject.GetRoi();
			this.Callout.Update(_roi, responsive ? RoiAnalysisMode.Responsive : RoiAnalysisMode.Normal);
		}
Example #7
0
	    public bool SupportsRoi(Roi roi)
		{
			return roi is ProtractorRoiInfo;
		}
Example #8
0
        ////TODO (cr Feb 2010): All the analysis should really be done in the ProtractorRoiInfo.
        //public string Analyze(ProtractorRoiInfo roiInfo, RoiAnalysisMode mode)
        //{
        //    // Don't show the callout until the second ray is drawn
        //    if (roiInfo.Points.Count < 3)
        //        return SR.ToolsMeasurementSetVertex;

        //    List<PointF> normalizedPoints = NormalizePoints(roiInfo);

        //    double angle = Vector.SubtendedAngle(normalizedPoints[0], normalizedPoints[1], normalizedPoints[2]);

        //    return String.Format(SR.ToolsMeasurementFormatDegrees, Math.Abs(angle));
        //}

        //TODO (cr Feb 2010): All the analysis should really be done in the ProtractorRoiInfo.
        public IRoiAnalyzerResult Analyze(Roi roi, RoiAnalysisMode mode)
        {
            return Analyze((ProtractorRoiInfo) roi, mode);
        }
Example #9
0
 private void Analyze(bool responsive)
 {
     _roi = base.Subject.GetRoi();
     this.Callout.Update(_roi, responsive ? RoiAnalysisMode.Responsive : RoiAnalysisMode.Normal);
 }
			private void Analyze(bool responsive)
			{
				_roi = Subject.GetRoi();

				var currentCallout = Callout;
				var roiCallout = currentCallout as RoiCalloutGraphic;
				if (roiCallout == null)
				{
					if (currentCallout != null)
					{
						Graphics.Remove(currentCallout);
						currentCallout.Dispose();
					}
					roiCallout = new RoiCalloutGraphic {Color = Color};
					Graphics.Add(roiCallout);
					Callout = roiCallout;
				}
				roiCallout.Update(_roi, responsive ? RoiAnalysisMode.Responsive : RoiAnalysisMode.Normal);
			}
Example #11
0
 /// <summary>
 /// Forces the callout to update, allowing all the analyzers to recompute and update the text content of the callout immediately.
 /// </summary>
 /// <param name="roi">A particular region of interest information object to use when computing statistics.</param>
 public void Update(Roi roi)
 {
     this.Update(roi, RoiAnalysisMode.Normal);
 }