예제 #1
0
"""
###############################
draw spline using average position
of the center of the vertebrae
###############################
"""

data_folder = xray_dir + '/data/LL/'
result_folder = '/Users/ruhansa/Desktop/train/result/clf_blur_canny_1_20_0413/whole_boxes/'
if ~os._exists(result_folder):
    os.mkdir(result_folder)

starti = 2
endi = 10


for i in range(starti, endi+1):

    testn = str(i)
    fn = data_folder + testn + '.jpg'
    arr=filename2arr(fn)
    img = Image.open(open(fn, "rb"))

    fn = '/Users/ruhansa/Desktop/train/result/clf_blur_canny_1_20_0413/' + testn + '_boxes.pkl'
    boxes = pickle.load(open(fn, 'rb'))
    boxes, _, _ = non_max_suppression_center(boxes, overlapThresh=0.3)

    img = add_boxes(boxes, img)
    img.save(result_folder + testn + '.jpg')
예제 #2
0
    # report.write("==================== sample #: " + testn + "==========================\n")
    t0 = time.time()
    fn = data_folder + testn + '.jpg'
    arr = filename2arr(fn)
    img3 = Image.fromarray(arr)

    ### step1: get bounding boxes
    fn = prev_halves_folder + testn + '_half_boxes.pkl'
    halves = pickle.load(open(fn, "rb"))
    img3 = add_boxes(halves, img3)
    img3.show()
    if debug is True:
        raw_input("rough detection")

    img3 = Image.fromarray(arr)
    halves_b, halves_c, halves_wh= non_max_suppression_center(halves)
    pts=get_spline(halves_b, 0.2*arr.shape[0], 0.75*arr.shape[0])
    if pts is not None:
        img3 = add_boxes(halves_b, img3)
        img3.show()
        if debug is True:
            raw_input("clear out the clutter")
        img3 = add_points(pts, img3)
    img3.show()
    if debug is True:
        raw_input("rough curvature line")

    fn = prev_whole_folder + testn + '_boxes.pkl'
    wholes = pickle.load(open(fn, "rb"))
    wholes_b, wholes_c, wholes_wh= non_max_suppression_center(wholes, overlapThresh=0.3)
    img3 = Image.fromarray(arr)