Esempio n. 1
0
def judge_vowel(image, index, vewol):
    row, col = image.shape
    new_vewol = []
    if (index > 10):
        image_vowel = image[0:index, :]
        for i in range(col):
            image[index][i] = 0
        lb_image = measure.label(image_vowel, connectivity=1)
        regions = measure.regionprops(lb_image)
        k = 1
        num = len(regions)
        for region in regions:
            if (region.area < 30):
                continue
            min_row, min_col, max_row, max_col = region.bbox
            if (max_col - min_col) / (max_row - min_row) > 2.5:
                for i in range(len(vewol)):
                    x, y = vewol[i][0], vewol[i][1]
                    print('x  y yyyyyyyyyyyy', x, y)
                    print(min_row, min_col, max_row, max_col)
                    print("Using SVM to predict...")
                    if (max_row - min_row < 6):
                        break
                    images = segmentation_image(region.image, x - min_col,
                                                y - min_row)
                    if (len(images) < 2):
                        break
                    image1 = images[0]
                    image2 = images[1]
                    print([x, y])
                    # plt.subplot(2, 2, 1).imshow(image1.astype(np.int8))
                    ratio1, classification = get_class_and_ratio(
                        image1.astype(np.uint8) * 255)
                    print(1, ratio1, classification)
                    # plt.subplot(2, 2, 2).imshow(image2.astype(np.int8))
                    ratio2, classification = get_class_and_ratio(
                        image2.astype(np.uint8) * 255)
                    print(2, ratio2, classification)
                    if (ratio1 > 0 and ratio2 > 0):
                        new_vewol.append([x, y])
    #     plt.subplot(212).imshow(image)
    #     plt.show()
    # else:
    #     plt.subplot(111).imshow(image)
    #     plt.show()
    # return False,image
    return new_vewol
Esempio n. 2
0
def judge_vowel(image, index):
    row, col = image.shape
    if (index > 10):
        image_vowel = image[0:index - 2, :]
        for i in range(col):
            image[index - 2][i] = 0
        lb_image = measure.label(image_vowel, connectivity=1)
        regions = measure.regionprops(lb_image)
        k = 1
        num = len(regions)
        for region in regions:
            print("坎坎坷咳咳咳扩扩扩扩扩扩扩扩扩扩扩扩扩扩扩扩扩扩扩扩扩扩")
            plt.subplot(2, num, k).imshow(region.image.astype(np.int8))
            ratio, classification = get_class_and_ratio(
                region.image.astype(np.uint8) * 255)
            print(k, ratio, classification)
            k = k + 1
        plt.subplot(212).imshow(image)
        plt.show()
    else:
        plt.subplot(111).imshow(image)
        plt.show()
    return False, image