Esempio n. 1
0
def analyse_dir(dir_path, dist_per_pixel):
    """
        Segment and score every image in a directory

        :param dir_path: Path to directory containing images to be scored
        :param dist_per_pixel: Distance in µm represented by one pixel of an
        image in the given directory.
        :return: An array of number of cells for each score - 0 to 8
    """
    if not os.path.isdir(dir_path):
        raise ValueError('Invalid directory path')
    cell_dir = dir_path + 'cells/'
    create_or_wipe_dir(cell_dir)
    cnt = 0
    # Segment
    for imgPath in all_images_in_dir(dir_path):
        img = cv2.imread(imgPath)
        cnt = segment_region(img, cell_dir, cnt, dist_per_pixel)

    # Score
    totals = np.zeros((9, ), np.uint32)
    for imgPath in all_images_in_dir(cell_dir):
        img = cv2.imread(imgPath)
        score_value = score(img)
        totals[score_value] += 1

    # print_scores(totals)
    return totals
Esempio n. 2
0
def analyse_img(img):
    """
        Segment and score a single image

        :param img: Loaded image to be scored (ie not a path)
        :return: An array of number of cells for each score - 0 to 8
    """
    cell_dir = 'cells/'
    create_or_wipe_dir(cell_dir)
    segment_region(img, cell_dir, 0, 1)

    totals = np.zeros((9, ), np.uint32)
    for imgPath in all_images_in_dir(cell_dir):
        img = cv2.imread(imgPath)
        score_value = score(img)
        totals[score_value] += 1

    print_scores(totals)
    return totals
Esempio n. 3
0
def test_simple_8():
    score_value = score(test_cells[8])
    assert score_value == 8
Esempio n. 4
0
def test_simple_7():
    score_value = score(test_cells[7])
    assert score_value == 7
Esempio n. 5
0
def test_simple_6():
    score_value = score(test_cells[6])
    assert score_value == 6
Esempio n. 6
0
def test_simple_5():
    score_value = score(test_cells[5])
    assert score_value == 5
Esempio n. 7
0
def test_simple_4():
    score_value = score(test_cells[4])
    assert score_value == 4
Esempio n. 8
0
def test_simple_3():
    score_value = score(test_cells[3])
    assert score_value == 3
Esempio n. 9
0
def test_simple_2():
    score_value = score(test_cells[2])
    assert score_value == 2
Esempio n. 10
0
def test_simple_1():
    score_value = score(test_cells[1])
    assert score_value == 1
Esempio n. 11
0
def test_simple_0():
    score_value = score(test_cells[0])
    assert score_value == 0