コード例 #1
0
ファイル: test_9.py プロジェクト: sssruhan1/xray
high_pass = gray - gaussed
idx = 0 > high_pass
high_pass[idx] = 0

# binarize the result
idx = high_pass >= 0.05
high_pass[idx] = 1.0
idx = high_pass < 0.05
high_pass[idx] = 0.0

# use hough transform to detect straight lines__ raw lines
from src.hough import hough_vertical_mask

fn = result_dir + "hough_line"
ptsv, linesv = hough_vertical_mask(high_pass, img, fn, save=False, show=False)

# get lined image__ use brush to widen the lines
from src.util import add_wide_lines

canvas = Image.fromarray(np.zeros((height, width), dtype=np.uint8))
lined = add_wide_lines(linesv, canvas, height, width)

# ========================= test_6 ===================================
# find connected components and label them
from scipy import ndimage

labeled, num_obj = ndimage.label(lined == True)

# set the highest and lowest point of each component as start and end point
from src.util import saveline
コード例 #2
0
ファイル: test_7.py プロジェクト: sssruhan1/xray
high_pass = gray - gaussed
idx = 0 > high_pass
high_pass[idx] = 0

# binarize the result
idx = high_pass >= 0.05
high_pass[idx] = 1.0
idx = high_pass < 0.05
high_pass[idx] = 0.0

# use hough transform to detect straight lines
from src.hough import hough_vertical_mask

fn = result_dir + "hough_line"
ptsv, linesv = hough_vertical_mask(high_pass, fn, save=True)

# get lined image
from src.util import add_wide_lines

canvas = Image.fromarray(np.zeros((height, width), dtype=np.uint8))
lined = add_wide_lines(linesv, canvas, height, width)
fn = result_dir + "added_wide_lines"
from src.util import saveimage_binary

saveimage_binary(lined, fn, "added wide lines")

# ========================= test_6 ===================================
# find connected components and label them
from scipy import ndimage