|
@@ -102,6 +102,36 @@ namespace bbiwarg.Images
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public Int16[] getSegmentationDepth()
|
|
|
+ {
|
|
|
+ //get first peak
|
|
|
+ Int16 firstMaxIndex = 0;
|
|
|
+
|
|
|
+ for (Int16 i = 0; i < histogram.Length; i++) {
|
|
|
+ if (histogram[i] > histogram[firstMaxIndex]) {
|
|
|
+ firstMaxIndex = i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // get second peak
|
|
|
+ Int16 minDistance = 20; // mm
|
|
|
+ Int16 secondMaxIndex = 0;
|
|
|
+ for (Int16 i = 0; i < histogram.Length; i++) {
|
|
|
+ if (Math.Abs(firstMaxIndex - i) > minDistance && histogram[i] > histogram[secondMaxIndex]) {
|
|
|
+ secondMaxIndex = i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Int16 minDepth = getMinDepth();
|
|
|
+
|
|
|
+ Int16[] result = new Int16[3];
|
|
|
+ result[0] = (Int16) (Math.Min(firstMaxIndex, secondMaxIndex) + minDepth);
|
|
|
+ result[1] = (Int16) ((firstMaxIndex + secondMaxIndex) / 2 + minDepth);
|
|
|
+ result[2] = (Int16) (Math.Max(firstMaxIndex, secondMaxIndex) + minDepth);
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
public Int16 getPeakDepth()
|
|
|
{
|
|
|
Int16 minDepth = getMinDepth();
|