Ejemplo n.º 1
0
    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
    #     # 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)