예제 #1
0
        private static Line GetTriangleAltitude(PolygonalRoiTests.PolygonShape triangleShape, int indexAngle)
        {
            PointF point = PointF.Empty;

            Vector.DistanceFromPointToLine(triangleShape[indexAngle], triangleShape[(indexAngle + 1) % 3], triangleShape[(indexAngle + 2) % 3], ref point);
            return(new Line(triangleShape[indexAngle], point));
        }
예제 #2
0
        public void TestLengthMeasurementIsometricPixelAspectRatio()
        {
            //    A
            // c / \ b
            //  B---C
            //    a
            // various lengths on an equilateral triangle figure
            // these expected values were independently computed by hand
            PolygonalRoiTests.PolygonShape triangleShape = PolygonalRoiTests.PolygonShape.Triangle;

            Line sideA = GetTriangleSide(triangleShape, 0);

            base.TestRoiLengthMeasurement(ImageKey.Aspect01, sideA, 200);
            base.TestRoiLengthMeasurement(ImageKey.Aspect02, sideA, 200);
            base.TestRoiLengthMeasurement(ImageKey.Aspect03, sideA, 8, 0.01, Units.Centimeters);
            base.TestRoiLengthMeasurement(ImageKey.Aspect04, sideA, 8, 0.01, Units.Centimeters);

            Line sideB = GetTriangleSide(triangleShape, 1);

            base.TestRoiLengthMeasurement(ImageKey.Aspect01, sideB, 200);
            base.TestRoiLengthMeasurement(ImageKey.Aspect02, sideB, 200);
            base.TestRoiLengthMeasurement(ImageKey.Aspect03, sideB, 8, 0.01, Units.Centimeters);
            base.TestRoiLengthMeasurement(ImageKey.Aspect04, sideB, 8, 0.01, Units.Centimeters);

            Line sideC = GetTriangleSide(triangleShape, 2);

            base.TestRoiLengthMeasurement(ImageKey.Aspect01, sideC, 200);
            base.TestRoiLengthMeasurement(ImageKey.Aspect02, sideC, 200);
            base.TestRoiLengthMeasurement(ImageKey.Aspect03, sideC, 8, 0.01, Units.Centimeters);
            base.TestRoiLengthMeasurement(ImageKey.Aspect04, sideC, 8, 0.01, Units.Centimeters);

            // the altitude of these triangles in pixels can be computed normally by dropping a line perpendicular to the selected base
            // when computing in centimetres (and thus adjusting for pixel aspect ratio), the altitude is actually the bisector in the
            // triangle before adjusting for pixel aspect ratio - because these triangles are supposed to be equilateral, in which case
            // the bisectors are also the altitudes.

            Line altitudeA = GetTriangleAltitude(triangleShape, 0);

            base.TestRoiLengthMeasurement(ImageKey.Aspect01, altitudeA, 173);
            base.TestRoiLengthMeasurement(ImageKey.Aspect02, altitudeA, 173);
            Line bisectorA = GetTriangleBisector(triangleShape, 0);

            base.TestRoiLengthMeasurement(ImageKey.Aspect03, bisectorA, 6.9241, 0.01, Units.Centimeters);
            base.TestRoiLengthMeasurement(ImageKey.Aspect04, bisectorA, 6.9241, 0.01, Units.Centimeters);

            Line altitudeB = GetTriangleAltitude(triangleShape, 1);

            base.TestRoiLengthMeasurement(ImageKey.Aspect01, altitudeB, 173);
            base.TestRoiLengthMeasurement(ImageKey.Aspect02, altitudeB, 173);
            Line bisectorB = GetTriangleBisector(triangleShape, 1);

            base.TestRoiLengthMeasurement(ImageKey.Aspect03, bisectorB, 6.9241, 0.01, Units.Centimeters);
            base.TestRoiLengthMeasurement(ImageKey.Aspect04, bisectorB, 6.9241, 0.01, Units.Centimeters);

            Line altitudeC = GetTriangleAltitude(triangleShape, 2);

            base.TestRoiLengthMeasurement(ImageKey.Aspect01, altitudeC, 173);
            base.TestRoiLengthMeasurement(ImageKey.Aspect02, altitudeC, 173);
            Line bisectorC = GetTriangleBisector(triangleShape, 2);

            base.TestRoiLengthMeasurement(ImageKey.Aspect03, bisectorC, 6.9241, 0.01, Units.Centimeters);
            base.TestRoiLengthMeasurement(ImageKey.Aspect04, bisectorC, 6.9241, 0.01, Units.Centimeters);
        }
예제 #3
0
 private static Line GetTriangleBisector(PolygonalRoiTests.PolygonShape triangleShape, int indexAngle)
 {
     return(new Line(triangleShape[indexAngle], Vector.Midpoint(triangleShape[(indexAngle + 1) % 3], triangleShape[(indexAngle + 2) % 3])));
 }
예제 #4
0
 private static Line GetTriangleSide(PolygonalRoiTests.PolygonShape triangleShape, int indexOppositeAngle)
 {
     return(new Line(triangleShape[(indexOppositeAngle + 1) % 3], triangleShape[(indexOppositeAngle + 2) % 3]));
 }