Example #1
0
    def get_mask(self, im: np.array):
        """
        get_mask(im)
    
        Function to compute the mask of an certain image,in this case is done 
        in HSV system to an image with Y-histogram equalised
    
        Parameters   Value
       ----------------------
        'im'          Dataset image
    
        Returns the mask, binary image with the detections.
        """
        # Equalization of the Y channel of the image
        im = histogram_equalization(im, False)

        # Color segmentation in HSV
        mask, im = segregation(im, 'hsv')

        # Mask Blurring
        mask = blur(mask)

        # Hole filling
        mask = fill_holes(mask)

        # Compute the final mask
        mask = discard_geometry.get_mask(mask)

        return mask, im
Example #2
0
    def get_mask(self, im: np.array):
        """
        get_mask(im)
    
        Function to compute the mask of an certain image,in this case is done 
        in RGB system
    
        Parameters   Value
       ----------------------
        'im'          Dataset image
    
        Returns the mask, binary image with the detections.
        """
        # Color segmentation in RGB
        mask, im = segregation(im, 'rgb')

        # Hole filling
        mask = fill_holes(mask)

        # Mask Blurring
        mask = blur(mask)

        # Compute the final mask
        mask = discard_geometry.get_mask(mask)

        return mask, im
Example #3
0
    def get_mask(self, im: np.array):
        """
        get_mask(im)
    
        Function to compute the mask of an certain image,in this case is done 
        in HSV system
    
        Parameters   Value
       ----------------------
        'im'          Dataset image
    
        Returns the mask, binary image with the detections.
        """

        # Color segmentation in HSV
        mask, im = segregation(im, 'hsv')

        mask = morpho(mask)

        regions = get_cc_regions(mask)

        # Compute the final mask
        mask, regions = discard_geometry.get_mask(mask, regions)

        return regions, mask, im
Example #4
0
    def get_mask(self, im: np.array):
        mask, im = segregation(im, 'hsv')

        mask = morpho(mask)

        mask, regions = sliding_window(mask)

        return regions, mask, im
    def get_mask(self, im: np.array):
        # Color segmentation in HSV
        mask, im = segregation(im, 'hsv')

        mask = morpho(mask)

        mask, regions = integral(mask)

        return regions, mask, im
    def get_mask(self, im: np.array):
        # Color segmentation in HSV
        mask, im = segregation(im, 'hsv')

        mask = morpho(mask)
        mask = fill_holes(mask)

        mask, regions = convolution(mask)
        mask, regions = discard_geometry.get_mask(mask, regions)

        return regions, mask, im
Example #7
0
    'mask'       Binary image with the detections obtained by the image segmentation
    
    returns the improved mask 
     
    """

    im_floodfill = mask.copy()

    # Mask used to flood filling.
    # Notice the size needs to be 2 pixels than the image.
    h, w = im_floodfill.shape[:2]
    filling_mask = np.zeros((h + 2, w + 2), np.uint8)

    cv2.floodFill(im_floodfill, filling_mask, (0, 0), 255)

    im_floodfill_inv = cv2.bitwise_not(im_floodfill)

    im_out = mask | im_floodfill_inv

    return im_out


if __name__ == '__main__':
    im = cv2.imread('../../datasets/train/00.000948.jpg')
    mask_hsv = segregation(im, 'hsv')
    mask_hsv = get_mask(mask_hsv)
    cv2.imshow('image', im)
    cv2.imshow('mask', mask_hsv)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
    def get_mask(self, im: np.array):
        mask, im = segregation(im, 'hsv')
        regions = template_matching.template_matching_global(mask)
        mask = np.zeros(im.shape[0:2])

        return regions, mask, im