using System;
using System.Runtime.Serialization;
using AI.Common;
namespace AutoBlineCalculationLib
{
///
/// B线评分类别
///
public enum EnumBlineScoreType
{
///
/// 空
///
Null = 0,
///
/// 孤立B线
///
IsolatedBLine = 1,
///
/// 融合B线
///
FusionBLine = 2,
///
/// 肺实变
///
LungConsolidation = 3,
}
///
/// B线评分相关信息
///
public struct BLineScoringInfo
{
private EnumBlineScoreType _type;
private IUltrasoundImageRegion _ultrasoundImageRegion;
///
/// B线评分类别
///
public EnumBlineScoreType Type
{
get => _type;
set => _type = value;
}
public IUltrasoundImageRegion UltrasoundImageRegion
{
get => _ultrasoundImageRegion;
set => _ultrasoundImageRegion = value;
}
///
/// 构造函数
///
///
///
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);
}
}
///
/// B线模型分割类别
///
public enum EnumBlineRecognizedObjectType
{
///
/// 空
///
Null = 0,
///
/// 胸膜线
///
Pline = 1,
///
/// B线
///
Bline = 2,
///
/// A线
///
Aline = 3,
///
/// 肺实变
///
LungConsolidation = 4,
}
///
/// B线模型识别到的目标的相关信息
///
public struct BlineRecognizedObjectInfo
{
private EnumBlineRecognizedObjectType _type;
private float _confidence;
private Point2D[] _contour;
///
/// 被识别到的目标的类别
///
public EnumBlineRecognizedObjectType Type
{
get => _type;
set => _type = value;
}
///
/// 识别正确的可能性
///
public float Confidence
{
get => _confidence;
set => _confidence = value;
}
///
/// 该目标的轮廓
///
public Point2D[] Contour
{
get => _contour;
set => _contour = value;
}
///
/// 构造函数
///
///
///
///
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());
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);
}
}
///
/// 感兴趣区域相关信息
///
public struct RegionOfInterestInfo
{
#region private
private float _regionOfInterestScore;
private IUltrasoundImageRegion _ultrasoundRegionOfInterest;
#endregion
///
/// 单帧图像中感兴趣区域得分
///
public float RegionOfInterestScore
{
get => _regionOfInterestScore;
set => _regionOfInterestScore = value;
}
public IUltrasoundImageRegion UltrasoundRegionOfInterest
{
get => _ultrasoundRegionOfInterest;
set => _ultrasoundRegionOfInterest = value;
}
///
/// 构造函数
///
///
///
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);
}
}
///
/// 单幅图像的B线计算结果
///
[DataContract]
public struct BlineScoringResults
{
#region field
private int _blineScore;
private BLineScoringInfo[] _blineScoringInfo;
private BlineRecognizedObjectInfo[] _recognizedObjects;
private RegionOfInterestInfo _regionOfInterestInfo;
#endregion
#region public funcs
///
/// 单幅图像中B线的评分
///
public int BlineScore { get => _blineScore; set => _blineScore = value; }
///
/// 单幅图像中B线计算的目标
///
public BLineScoringInfo[] BlineScoringInfo
{
get => _blineScoringInfo;
set => _blineScoringInfo = value;
}
///
/// B线模型分割目标
///
public BlineRecognizedObjectInfo[] RecognizedObjects
{
get => _recognizedObjects;
set => _recognizedObjects = value;
}
public RegionOfInterestInfo RegionOfInterestInfo
{
get => _regionOfInterestInfo;
set => _regionOfInterestInfo = value;
}
///
/// 构造函数
///
///
///
///
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(), Array.Empty(), 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
}
}