當前位置: 首頁>>代碼示例>>Python>>正文


Python cv2.CV_32S屬性代碼示例

本文整理匯總了Python中cv2.CV_32S屬性的典型用法代碼示例。如果您正苦於以下問題:Python cv2.CV_32S屬性的具體用法?Python cv2.CV_32S怎麽用?Python cv2.CV_32S使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在cv2的用法示例。


在下文中一共展示了cv2.CV_32S屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _connect_components_analysis

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import CV_32S [as 別名]
def _connect_components_analysis(image):
    """
    connect components analysis to remove the small components
    :param image:
    :return:
    """
    if len(image.shape) == 3:
        gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    else:
        gray_image = image

    return cv2.connectedComponentsWithStats(gray_image, connectivity=8, ltype=cv2.CV_32S) 
開發者ID:MaybeShewill-CV,項目名稱:lanenet-lane-detection,代碼行數:14,代碼來源:lanenet_postprocess.py

示例2: find_connected

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import CV_32S [as 別名]
def find_connected(score_map, threshold=0.7):
    binary_map = (score_map > threshold).astype(np.uint8)
    connectivity = 8
    output = cv2.connectedComponentsWithStats(binary_map, connectivity=connectivity, ltype=cv2.CV_32S)
    label_map = output[1]
    # show_image(np.asarray(label_map * 100.0, np.uint8))
    return np.max(label_map), label_map 
開發者ID:UpCoder,項目名稱:ICPR_TextDection,代碼行數:9,代碼來源:tools.py

示例3: _connect_components_analysis

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import CV_32S [as 別名]
def _connect_components_analysis(image):
        """

        :param image:
        :return:
        """
        if len(image.shape) == 3:
            gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
        else:
            gray_image = image

        return cv2.connectedComponentsWithStats(gray_image, connectivity=8, ltype=cv2.CV_32S) 
開發者ID:stesha2016,項目名稱:lanenet-enet-hnet,代碼行數:14,代碼來源:lanenet_postprocess.py

示例4: split_mask_erode_dilate

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import CV_32S [as 別名]
def split_mask_erode_dilate(mask, kernel=k_3x3, k=3):
    img_erosion = cv.erode(mask, kernel, iterations=k)
    output = cv.connectedComponentsWithStats(img_erosion, 4, cv.CV_32S)
    if output[0] < 2:
        return [mask], output[1]
    else:
        masks_res = []
        for idx in range(1, output[0]):
            res_m = (output[1] == idx).astype(np.uint8)
            res_m = cv.dilate(res_m, kernel, iterations=k)
            if res_m.sum() > 5:
                masks_res.append(res_m)
        return masks_res, output[1] 
開發者ID:gangadhar-p,項目名稱:NucleiDetectron,代碼行數:15,代碼來源:mask_morphology.py

示例5: obj_histogram

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import CV_32S [as 別名]
def obj_histogram(self, mask, label):
    # holders for predicted object and right object (easily calculate histogram)
    predicted = []
    labeled = []

    # get connected components in label for each class
    for i in range(self.num_classes):
      # get binary image for this class
      bin_lbl = np.zeros(label.shape)
      bin_lbl[label == i] = 1
      bin_lbl[label != i] = 0

      # util.im_gray_plt(bin_lbl,'class '+str(i))
      connectivity = 4
      output = cv2.connectedComponentsWithStats(
          bin_lbl.astype(np.uint8), connectivity, cv2.CV_32S)
      num_components = output[0]
      components = output[1]
      stats = output[2]
      centroids = output[3]

      for j in range(1, num_components):  # 0 is background (useless)
        # only process if it has more than 50pix
        if stats[j][cv2.CC_STAT_AREA] > 50:
          # for each component in each class, see the class with the highest percentage of pixels
          # make mask with just this component of this class
          comp_mask = np.zeros(label.shape)
          comp_mask[components == j] = 0
          comp_mask[components != j] = 1
          # mask the prediction
          masked_prediction = np.ma.masked_array(mask, mask=comp_mask)
          # get histogram and get the argmax that is not zero
          class_hist, _ = np.histogram(masked_prediction.compressed(),
                                       bins=self.num_classes, range=[0, self.num_classes])
          max_class = np.argmax(class_hist)
          # print("\nMax class: ",max_class,"  real: ",i)
          # util.im_gray_plt(comp_mask)
          # util.im_block()
          # sum an entry to the containers depending on right or wrong
          predicted.append(max_class)
          labeled.append(i)
    # for idx in range(len(predicted)):
    #   print(predicted[idx],labeled[idx])

    # histogram to count right and wrong objects
    histrange = np.array([[-0.5, self.num_classes - 0.5],
                          [-0.5, self.num_classes - 0.5]], dtype='float64')
    h_now, _, _ = np.histogram2d(np.array(predicted),
                                 np.array(labeled),
                                 bins=self.num_classes,
                                 range=histrange)

    return h_now 
開發者ID:PRBonn,項目名稱:bonnet,代碼行數:55,代碼來源:abstract_net.py


注:本文中的cv2.CV_32S屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。