Esempio n. 1
0
    def shape_factor_1(mask):
        """

        """
        cnt = Masks.extract_contour(mask)

        return Contours.shape_factor_1(cnt)
Esempio n. 2
0
    def compactness(mask):
        """
        Proportion between area and the shape of the ellipse
        :param mask:
        :return:
        """
        cnt = Masks.extract_contour(mask)

        return Contours.compactness(cnt)
Esempio n. 3
0
    def equivalent_ellipse_area(mask):
        """
        The area of the equivalent ellipse
        :param mask:
        :return:
        """
        cnt = Masks.extract_contour(mask)

        return Contours.equivalent_ellipse_area(cnt)
Esempio n. 4
0
    def shape(mask):
        """
        Relation between perimeter and area. Calc the elongation of an object
        :param mask:
        :return:
        """
        cnt = Masks.extract_contour(mask)

        return Contours.shape(cnt)
Esempio n. 5
0
    def circularity(mask):
        """
        @brief Calc the likeliness of an object to a circle
        :param mask: 1 channel image
        :return:
        """
        cnt = Masks.extract_contour(mask)

        return Contours.circularity(cnt)
Esempio n. 6
0
    def feret_angle(mask):
        """
        @brief Return the angle between the feret and the horizontal
        :param mask:
        :return:
        """
        cnt = Masks.extract_contour(mask)

        return Contours.orientation(cnt)
Esempio n. 7
0
    def breadth(mask):
        """
        @brief Calculates the minor diagonal of the ellipse from the contour
        :param mask:
        :return:
        """
        cnt = Masks.extract_contour(mask)

        return Contours.minor_axis(cnt)
Esempio n. 8
0
    def min_r(mask):
        """
        @brief Calculates the minor radius of the ellipse from the contour
        :param mask:
        :return:
        """
        cnt = Masks.extract_contour(mask)

        return Contours.min_r(cnt)
Esempio n. 9
0
    def max_r(mask):
        """
        @brief Calculates the radius of the enclosing circle of the contour
        :param mask:
        :return:
        """

        cnt = Masks.extract_contour(mask)

        return Contours.max_r(cnt)
Esempio n. 10
0
    def area_equivalent_diameter(mask):
        """
        @brief The diamater of the real area of the contour

        :param mask:
        :return:
        """
        cnt = Masks.extract_contour(mask)

        return Contours.area_equivalent_diameter(cnt)
Esempio n. 11
0
    def aspect_ratio(mask):
        """
        @brief Proportional relationship between its width and it's height
        :param mask: 2D Vector, 1 channel image
        :return:
        """

        cnt = Masks.extract_contour(mask)

        return Contours.aspect_ratio(cnt)
Esempio n. 12
0
    def sphericity(mask):
        """
        Proportion between the major and the minor feret

        :param mask:
        :return:
        """
        cnt = Masks.extract_contour(mask)

        return Contours.sphericity(cnt)
Esempio n. 13
0
    def roundness(mask):
        """
        Circularity corrected by the aspect ratio
        ref : https://progearthplanetsci.springeropen.com/articles/10.1186/s40645-015-0078-x
        :param mask: 1 channel image
        :return:
        """
        cnt = Masks.extract_contour(mask)

        return Contours.roundness(cnt)
Esempio n. 14
0
    def feret(mask):
        """
        @brief Calculates the major diagonal of the enclosing ellipse of the contour
        :param mask:
        :return:
        """

        cnt = Masks.extract_contour(mask)

        return Contours.major_axis(cnt)
Esempio n. 15
0
    def area(mask):
        """
        Calc the area of the object of the mask

        :param mask: 1 channel image
        :return:
        """
        cnt = Masks.extract_contour(mask)

        return Contours.area(cnt)
Esempio n. 16
0
    def perimeter_equivalent_diameter(mask):
        """
        @brief The diameter of the real perimeter of the contour

        :param mask: 2D Vector, 1 channel image
        :return:
        """
        cnt = Masks.extract_contour(mask)

        return Contours.perimeter_equivalent_diameter(cnt)
Esempio n. 17
0
    def rectangularity(mask):
        """
        @brief Calculates the area of the bounding box of the contour.

        :param mask: 1 channel image
        :return:
        """
        cnt = Masks.extract_contour(mask)

        return Contours.bounding_box_area(cnt)
Esempio n. 18
0
    def convex_hull_area(mask):
        """
        Calculates the area of the convex hull from the contour, using the same function that the area of any object.

        :param mask: 1 channel image
        :return:
        """
        cnt = Masks.extract_contour(mask)

        return Contours.convex_hull_area(cnt)
Esempio n. 19
0
    def convex_hull_perimeter(mask):
        """
        @brief Finds the perimeter of the convex-hull.

        :param mask: 1 channel image
        :return:
        """
        cnt = Masks.extract_contour(mask)

        return Contours.convex_hull_perimeter(cnt)
Esempio n. 20
0
    def perimeter(mask):
        """
        Calc the perimeter of the object in the mask

        :param mask: 1 channel image
        :return:
        """
        cnt = Masks.extract_contour(mask)

        return Contours.perimeter(cnt)
Esempio n. 21
0
    def convexity(mask):
        """
        @brief Calc the convexity of the contour

        The convexity is a measure of the curvature of an object. Is calc by the relation between the perimeter of
        the convex hull and the perimeter of the object.
        :param mask:
        :return:
        """
        cnt = Masks.extract_contour(mask)

        return Contours.convexity(cnt)
Esempio n. 22
0
    def center(mask):
        """
        @brief Calculate the centroid of a contour

        The centroid of a plane figure is the arithmetic mean of all the point in the figure.

        :param mask:  1 channel image
        :return:
        """
        cnt = Masks.extract_contour(mask)

        return Contours.center(cnt)
Esempio n. 23
0
    def bounding_box_area(mask, screen=False):
        """
        @brief Calculates the area of the bounding box of the contour.

        :param mask: 1 channel image
        :param screen: Boolean
        :return:
        """

        cnt = Masks.extract_contour(mask)

        if screen:
            rect = cv2.minAreaRect(cnt)
            box = cv2.boxPoints(rect)
            box = np.int0(box)
            mask_cp = copy(mask)
            cv2.drawContours(mask_cp, [box], -1, (100, 100, 100), 20)

            plt.imshow(mask_cp)
            plt.show()

        return Contours.bounding_box_area(cnt)
Esempio n. 24
0
    def eccentricity(mask, screen=False):
        """
        @brief Calc how much the conic section deviates from being circular

        For any point of a conic section, the distance between a fixed point F and a fixed straight line l is always
        equal to a positive constant, the eccentricity. Is calculed by the relation between the two diagonals of the
        elipse.

        :param mask: 1 channel image
        :param screen:
        :return:
        """
        cnt = Masks.extract_contour(mask)

        if screen:
            mask_cp = copy(mask)
            ellipse = cv2.fitEllipse(cnt)
            cv2.ellipse(mask_cp, ellipse, (100, 100, 100), 7)
            plt.imshow(mask_cp)
            plt.show()

        return Contours.eccentricity(cnt)
Esempio n. 25
0
    def solidity(mask, screen=False):
        """
        Calculates the proportion between the area of the object in the mask and the convex-hull
        :param mask: 1 channel image
        :param screen:
        :return:
        """
        cnt = Masks.extract_contour(mask)

        if screen:
            hull = cv2.convexHull(cnt, returnPoints=False)
            defects = cv2.convexityDefects(cnt, hull)
            mask_cp = copy(mask)
            for i in range(defects.shape[0]):
                s, e, f, d = defects[i, 0]
                start = tuple(cnt[s][0])
                end = tuple(cnt[e][0])
                cv2.line(mask_cp, start, end, [100, 100, 100], 10)

            plt.imshow(mask_cp)
            plt.show()

        return Contours.solidity(cnt)