示例#1
0
def resize_to_cell_size(the_ragion, interpolation = cv2.INTER_AREA):
    # the_ragion.shape.pl()
    heighted_ragion = Image.resize_keeping_ratio_by_fixed_length(the_ragion, IMG_SIZE, interpolation)
    # heighted_ragion.shape.pl()
    standard_ragion = Ragion.fill(heighted_ragion,(IMG_SIZE,IMG_SIZE))
    # standard_ragion.shape.pl()
    return standard_ragion
示例#2
0
def identify_wrong_number(number_ragions, difference, show_actual=True):
    all_number_images = generate_number_images()
    identified_number_ragions = number_ragions[:]
    for index,_,actual in difference:
        height, width = number_ragions[index].shape
        if show_actual:
            number_ragions[index] = Image.resize_keeping_ratio_by_height(all_number_images[actual], height)
            height, width = number_ragions[index].shape
        identified_number_ragions[index] = Ragion.fill(number_ragions[index], (height+2, width+2), 1)
    return identified_number_ragions
    def adjust_one(the_ragion):
        # the_ragion = cv2.GaussianBlur(the_ragion, ksize=(5,5), sigmaX=0)
        # blockSize = the_ragion.shape[1]/2
        # if blockSize % 2 == 0:
        #     blockSize += 1
        # thresholded_ragion = cv2.adaptiveThreshold(the_ragion,WHITE,
        #     cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRESH_BINARY_INV, blockSize=blockSize, C=2)
        # thresholded_ragion = Image.threshold_white_with_mean_percent(the_ragion, 0.70)
        threshold_value = Ragion.cal_threshold_value(the_ragion, square_ragion, 0.70)
        thresholded_ragion = Image.threshold_white(the_ragion, threshold_value)

        return thresholded_ragion
def resize_to_cell_size(the_ragion):
    heighted_ragion = resize_keeping_ratio_by_height(the_ragion, IMG_SIZE)
    standard_ragion = Ragion.fill(heighted_ragion, (IMG_SIZE, IMG_SIZE))
    return standard_ragion
    #     # Display.image(gray_image)

    with test("get clear number ragion"):
        som_svm = MultipleSvm.load_variables(Smo, data_file_helper.SUPPLEMENT_RESULT_PATH)
        file_path = Resource.get_test_path("sample_15_null_38_image.jpg")
        the_ragion = cv2.imread(file_path, 0)
        # the_ragion.mean().ppl()
        # the_ragion.ppl()
        # thresholded_ragion = Image.threshold_white_with_mean_percent(the_ragion, 0.8)
        # thresholded_ragion.ppl()
        # Display.image(thresholded_ragion)
        file_path = Resource.get_test_path("sample_15_square.jpg")
        square_ragion = cv2.imread(file_path, 0)
        # square_ragion.mean().ppl()

        threshold_value = Ragion.cal_threshold_value(the_ragion, square_ragion, 0.69)
        thresholded_ragion = Image.threshold_white(the_ragion, threshold_value)
        # thresholded_ragion = cv2.adaptiveThreshold(the_ragion, 255,
        #     cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRESH_BINARY_INV, blockSize=7, C=2)
        cell_rect = nonzero_rect.analyze_from_center(thresholded_ragion)
        if cell_rect:
            cell_ragion = Rect.get_ragion(cell_rect, thresholded_ragion)
        cell_rect.pl()
        # Display.image(cell_ragion)

        file_path = Resource.get_test_path("sample_19_07_05_image.jpg")
        the_ragion = cv2.imread(file_path, 0)
        # the_ragion.mean().ppl()

        file_path = Resource.get_test_path("sample_19_square.jpg")
        square_ragion = cv2.imread(file_path, 0)