fn = result_dir + '/' + testn + '_boxes.pkl' pickle.dump(boxes, open(fn, "wb")) img=add_boxes(boxes, img) img.save(result_dir +'/' + testn +'_boxes.jpg') # img = Image.fromarray(arr) # boxes = non_max_suppression_merge(boxes, overlapThresh=0.1) # img = add_boxes(boxes, img) # img.save(result_dir + '/' + testn + '_boxes_nms.jpg') # # img = Image.fromarray(arr) # fn = result_dir + '/' + testn + '_half_boxes.pkl' # pickle.dump(half_boxes, open(fn, "wb")) # img=add_boxes(half_boxes, img) # img.save(result_dir +'/' + testn +'_half_boxes.jpg') m, s = divmod(int( time.time() - t0), 60) h, m = divmod(m, 60) report.write("--- time elapsed for classification: %d:%02d:%02d " %(h, m, s) + " ---\n") if step2 is True: #### here goes canny, hough and GVF, snake pts = [] img = Image.fromarray(arr) pts = edge_detect(boxes, arr, show=True) img = add_points(pts, img) img.show() report.close()
img3 =Image.open(rawfn) add_v_list = search_up(edges=ret, folder=folder, n=4, v = v_list[0], debug=DEBUG, raw =img3) for v in add_v_list: v_list.insert(0, v) folder= '/Users/ruhansa/Desktop/result/xray/search_down4' img2 =Image.open(rawfn) add_v_list = search_down(edges=ret, folder=folder, n=4, v = v_list[-1], raw=img2, debug=DEBUG) for v in add_v_list: v_list.append(v) from src.utils.util import batch_extend batch_extend(v_list, canny1) from src.utils.io import add_lines, add_points img1 =Image.open(rawfn) for v in v_list: if v.topline is not None: print v.topline.line add_points(v.topline.extend_pts_left, img1) add_points(v.topline.extend_pts_right, img1) add_lines([v.topline.line], img1) if v.bottomline is not None: print v.bottomline.line add_points(v.bottomline.extend_pts_left, img1) add_points(v.bottomline.extend_pts_right, img1) add_lines([v.bottomline.line], img1) img1.show() fn = '/Users/ruhansa/Desktop/result/xray/search_up_down'+ datetime.datetime.now().strftime("%Y%m%d%H%M") + '.jpg' img1.save(fn, 'JPEG')
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) if pts is not None: img3 = add_boxes(wholes_b, img3) img3 = add_points(pts, img3) img3.show() if debug is True: raw_input("finer detect")