from src.utils.util import extend_line_canny_points
canny1 = my_canny(arr[:, :, 0], fn, sigma=1, save=True, show=True)
from src.utils.util import line_struct
lines = [] # store line structure with extended points and original lines, eliminate extreme lines
for line in lines_init:
    l = line_struct()
    l.line = line
    left, right = extend_line_canny_points(line, canny1)
    if left is not -1:
        l.extend_pts_left = left
        l.extend_pts_right = right
    lines.append(l)

## 5. sort the lines to put into vetebra_structure. eliminate extreme lines
from src.utils.util import sortlines
lines_sorted = sortlines(lines)
from src.utils.util import construct_vertebra_list
v_list = construct_vertebra_list(lines_sorted)


from src.utils.util import search_up, search_down
folder= '/Users/ruhansa/Desktop/result/xray/search_up4'
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)
Example #2
0
                        midx = l.getMidX()
                        midy = l.getMidY()
                        x_idx = np.where(pts[:, 1] == midy)
                        if x_idx is None:
                            # treat it as invalid
                            continue
                        else:
                            if abs(midx - pts[x_idx, 0]) < mean/2 :
                                lls.append(l)
                    else:
                        lls.append(l)


        ## 5. sort the lines and delete extreme lines
        from src.utils.util import sortlines
        lines_sorted = sortlines(lls)
        img3 = add_lines(houghs, img3)
        img3.show()
        fn = result_dir + testn + '_hough.jpg'
        img3.save(fn)

        img2 = Image.fromarray(arr)
        for line in lines_sorted:
            img2=add_points(line.extend_pts_left, img2)
            img2=add_points(line.extend_pts_right, img2)
            img2=add_lines([line.line], img2)

        img2.show()
        if debug is True:
            raw_input("refine curvature")