123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455 |
- using System;
- using System.Runtime.Serialization;
- using AI.Common;
- namespace AutoBlineCalculationLib
- {
- /// <summary>
- /// B线评分类别
- /// </summary>
- public enum EnumBlineScoreType
- {
- /// <summary>
- /// 空
- /// </summary>
- Null = 0,
- /// <summary>
- /// 孤立B线
- /// </summary>
- IsolatedBLine = 1,
- /// <summary>
- /// 融合B线
- /// </summary>
- FusionBLine = 2,
- /// <summary>
- /// 肺实变
- /// </summary>
- LungConsolidation = 3,
- }
- /// <summary>
- /// B线评分相关信息
- /// </summary>
- public struct BLineScoringInfo
- {
- private EnumBlineScoreType _type;
- private IUltrasoundImageRegion _ultrasoundImageRegion;
- /// <summary>
- /// B线评分类别
- /// </summary>
- public EnumBlineScoreType Type
- {
- get => _type;
- set => _type = value;
- }
- public IUltrasoundImageRegion UltrasoundImageRegion
- {
- get => _ultrasoundImageRegion;
- set => _ultrasoundImageRegion = value;
- }
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="type"></param>
- /// <param name="ultrasoundImageRegion"></param>
- public BLineScoringInfo(EnumBlineScoreType type, IUltrasoundImageRegion ultrasoundImageRegion)
- {
- _type = type;
- _ultrasoundImageRegion = ultrasoundImageRegion;
- }
- public static readonly BLineScoringInfo Empty = new BLineScoringInfo(EnumBlineScoreType.Null, null);
- public bool Equals(BLineScoringInfo other)
- {
- return Equals(this, other);
- }
- public static bool Equals(BLineScoringInfo one, BLineScoringInfo other)
- {
- if (one.Type != other.Type || one.UltrasoundImageRegion != other.UltrasoundImageRegion)
- {
- return false;
- }
- return true;
- }
- public override bool Equals(object obj)
- {
- if (obj == null || !(obj is BLineScoringInfo))
- {
- return false;
- }
- BLineScoringInfo other = (BLineScoringInfo)obj;
- return Equals(this, other);
- }
- public static bool operator ==(BLineScoringInfo one, BLineScoringInfo other)
- {
- return Equals(one, other);
- }
- public static bool operator !=(BLineScoringInfo one, BLineScoringInfo other)
- {
- return !Equals(one, other);
- }
- }
- /// <summary>
- /// B线模型分割类别
- /// </summary>
- public enum EnumBlineRecognizedObjectType
- {
- /// <summary>
- /// 空
- /// </summary>
- Null = 0,
- /// <summary>
- /// 胸膜线
- /// </summary>
- Pline = 1,
- /// <summary>
- /// B线
- /// </summary>
- Bline = 2,
- /// <summary>
- /// A线
- /// </summary>
- Aline = 3,
- /// <summary>
- /// 肺实变
- /// </summary>
- LungConsolidation = 4,
- }
- /// <summary>
- /// B线模型识别到的目标的相关信息
- /// </summary>
- public struct BlineRecognizedObjectInfo
- {
- private EnumBlineRecognizedObjectType _type;
- private float _confidence;
- private Point2D[] _contour;
- /// <summary>
- /// 被识别到的目标的类别
- /// </summary>
- public EnumBlineRecognizedObjectType Type
- {
- get => _type;
- set => _type = value;
- }
- /// <summary>
- /// 识别正确的可能性
- /// </summary>
- public float Confidence
- {
- get => _confidence;
- set => _confidence = value;
- }
- /// <summary>
- /// 该目标的轮廓
- /// </summary>
- public Point2D[] Contour
- {
- get => _contour;
- set => _contour = value;
- }
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="type"></param>
- /// <param name="confidence"></param>
- /// <param name="contour"></param>
- public BlineRecognizedObjectInfo(EnumBlineRecognizedObjectType type, float confidence, Point2D[] contour)
- {
- _type = type;
- _confidence = confidence;
- _contour = contour;
- }
- public static readonly BlineRecognizedObjectInfo Empty = new BlineRecognizedObjectInfo(EnumBlineRecognizedObjectType.Null, 0, Array.Empty<Point2D>());
- public bool Equals(BlineRecognizedObjectInfo other)
- {
- return Equals(this, other);
- }
- public static bool Equals(BlineRecognizedObjectInfo one, BlineRecognizedObjectInfo other)
- {
- if (one.Type != other.Type || one.Confidence != other.Confidence)
- {
- return false;
- }
- if (one.Contour == null && other.Contour == null)
- {
- return true;
- }
- if ((one.Contour == null && other.Contour != null) || (one.Contour != null && other.Contour == null))
- {
- return false;
- }
- if (one.Contour.Length != other.Contour.Length)
- {
- return false;
- }
- for (int ni = 0; ni < one.Contour.Length; ni++)
- {
- if (one.Contour[ni] != other.Contour[ni])
- {
- return false;
- }
- }
- return true;
- }
- public override bool Equals(object obj)
- {
- if (obj == null || !(obj is BlineRecognizedObjectInfo))
- {
- return false;
- }
- BlineRecognizedObjectInfo other = (BlineRecognizedObjectInfo)obj;
- return Equals(this, other);
- }
- public static bool operator ==(BlineRecognizedObjectInfo one, BlineRecognizedObjectInfo other)
- {
- return Equals(one, other);
- }
- public static bool operator !=(BlineRecognizedObjectInfo one, BlineRecognizedObjectInfo other)
- {
- return !Equals(one, other);
- }
- }
- /// <summary>
- /// 感兴趣区域相关信息
- /// </summary>
- public struct RegionOfInterestInfo
- {
- #region private
- private float _regionOfInterestScore;
- private IUltrasoundImageRegion _ultrasoundRegionOfInterest;
- #endregion
- /// <summary>
- /// 单帧图像中感兴趣区域得分
- /// </summary>
- public float RegionOfInterestScore
- {
- get => _regionOfInterestScore;
- set => _regionOfInterestScore = value;
- }
- public IUltrasoundImageRegion UltrasoundRegionOfInterest
- {
- get => _ultrasoundRegionOfInterest;
- set => _ultrasoundRegionOfInterest = value;
- }
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="ultrasoundRegionOfInterest"></param>
- /// <param name="ultrasoundRegionOfInterest"></param>
- public RegionOfInterestInfo(float regionOfInterestScore, IUltrasoundImageRegion ultrasoundRegionOfInterest)
- {
- _regionOfInterestScore = regionOfInterestScore;
- _ultrasoundRegionOfInterest = ultrasoundRegionOfInterest;
- }
- public static readonly RegionOfInterestInfo Empty = new RegionOfInterestInfo(0, null);
- public bool Equals(RegionOfInterestInfo other)
- {
- return Equals(this, other);
- }
- public static bool Equals(RegionOfInterestInfo one, RegionOfInterestInfo other)
- {
- if (one.RegionOfInterestScore != other.RegionOfInterestScore || one.UltrasoundRegionOfInterest != other.UltrasoundRegionOfInterest)
- {
- return false;
- }
- return true;
- }
- public override bool Equals(object obj)
- {
- if (obj == null || !(obj is RegionOfInterestInfo))
- {
- return false;
- }
- RegionOfInterestInfo other = (RegionOfInterestInfo)obj;
- return Equals(this, other);
- }
- public static bool operator ==(RegionOfInterestInfo one, RegionOfInterestInfo other)
- {
- return Equals(one, other);
- }
- public static bool operator !=(RegionOfInterestInfo one, RegionOfInterestInfo other)
- {
- return !Equals(one, other);
- }
- }
- /// <summary>
- /// 单幅图像的B线计算结果
- /// </summary>
- [DataContract]
- public struct BlineScoringResults
- {
- #region field
- private int _blineScore;
- private BLineScoringInfo[] _blineScoringInfo;
- private BlineRecognizedObjectInfo[] _recognizedObjects;
- private RegionOfInterestInfo _regionOfInterestInfo;
- #endregion
- #region public funcs
- /// <summary>
- /// 单幅图像中B线的评分
- /// </summary>
- public int BlineScore { get => _blineScore; set => _blineScore = value; }
- /// <summary>
- /// 单幅图像中B线计算的目标
- /// </summary>
- public BLineScoringInfo[] BlineScoringInfo
- {
- get => _blineScoringInfo;
- set => _blineScoringInfo = value;
- }
- /// <summary>
- /// B线模型分割目标
- /// </summary>
- public BlineRecognizedObjectInfo[] RecognizedObjects
- {
- get => _recognizedObjects;
- set => _recognizedObjects = value;
- }
- public RegionOfInterestInfo RegionOfInterestInfo
- {
- get => _regionOfInterestInfo;
- set => _regionOfInterestInfo = value;
- }
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="blineScore"></param>
- /// <param name="blineScoringInfo"></param>
- /// <param name="recognizedObjects"></param>
- public BlineScoringResults(int blineScore, BLineScoringInfo[] blineScoringInfo, BlineRecognizedObjectInfo[] recognizedObjects, RegionOfInterestInfo regionOfInterestInfo)
- {
- _blineScore = blineScore;
- _blineScoringInfo = blineScoringInfo;
- _recognizedObjects = recognizedObjects;
- _regionOfInterestInfo = regionOfInterestInfo;
- }
- public static readonly BlineScoringResults Empty = new BlineScoringResults(0, Array.Empty<BLineScoringInfo>(), Array.Empty<BlineRecognizedObjectInfo>(), RegionOfInterestInfo.Empty);
- public bool Equals(BlineScoringResults other)
- {
- return Equals(this, other);
- }
- public static bool Equals(BlineScoringResults one, BlineScoringResults other)
- {
- if (one.BlineScore != other.BlineScore)
- {
- return false;
- }
- // BlineScoringInfo
- if (one.BlineScoringInfo == null && other.BlineScoringInfo == null)
- {
- return true;
- }
- if ((one.BlineScoringInfo != null && other.BlineScoringInfo == null) || (one.BlineScoringInfo == null && other.BlineScoringInfo != null))
- {
- return false;
- }
- if (one.BlineScoringInfo.Length != other.BlineScoringInfo.Length)
- {
- return false;
- }
- return true;
- // RecognizedObjects
- if (one.RecognizedObjects == null && other.RecognizedObjects == null)
- {
- return true;
- }
- if ((one.RecognizedObjects != null && other.RecognizedObjects == null) || (one.RecognizedObjects == null && other.RecognizedObjects != null))
- {
- return false;
- }
- if (one.RecognizedObjects.Length != other.RecognizedObjects.Length)
- {
- return false;
- }
- for (int ni = 0; ni < one.RecognizedObjects.Length; ni++)
- {
- if (one.RecognizedObjects[ni] != other.RecognizedObjects[ni])
- {
- return false;
- }
- }
- return true;
- // RegionOfInterestInfo
- if (one.RegionOfInterestInfo == null && other.RegionOfInterestInfo == null)
- {
- return true;
- }
- if ((one.RegionOfInterestInfo != null && other.RegionOfInterestInfo == null) || (one.RegionOfInterestInfo == null && other.RegionOfInterestInfo != null))
- {
- return false;
- }
- return true;
- }
- public override bool Equals(object obj)
- {
- if (obj == null || !(obj is BlineScoringResults))
- {
- return false;
- }
- BlineScoringResults other = (BlineScoringResults)obj;
- return Equals(this, other);
- }
- public static bool operator ==(BlineScoringResults one, BlineScoringResults other)
- {
- return Equals(one, other);
- }
- public static bool operator !=(BlineScoringResults one, BlineScoringResults other)
- {
- return !Equals(one, other);
- }
- #endregion
- }
- }
|