Skip to content

ludlows/CannyLine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cannly Line

A Line Segment Extraction Toolbox

Authour: https://github.com/ludlows

original image line extraction colorized line segments
test01 test01cannypf test01-color-out test01-out1
test02 test02cannypf test02-color-out test02-out1

Install

pip install https://github.com/ludlows/CannyLine/archive/refs/heads/master.zip

Usage

Colorizing Lines Segments

from cannyline import CannyPF, comp_edge_chain, color_imwrite

img_path = "./img/test02.jpg"
img = cv2.imread(img_path, 0)
cannypf = CannyPF(3, 70, img)
edgemap = cannypf.comp_edge_map()
edge_chain = comp_edge_chain(img, edgemap)
shape = list(img.shape) + [3]
name = img_path.split(".")[:-1]
name = ".".join(name)
name += "-color-out.jpg"
color_imwrite(edge_chain, shape, name)

Extracting Lines

from cannyline import MetaLine
img_path = "./img/test02.jpg"
img = cv2.imread(img_path, 0)
mtline = MetaLine()
lines = mtline.mtline_detect(img, 8,1)
out = 255* np.ones(img.shape, dtype=np.uint8)
for start_x, start_y, end_x, end_y, _ in lines:
    cv2.line(out, (int(start_x), int(start_y)), (int(end_x), int(end_y)), (0,0,0),thickness=1, lineType=cv2.LINE_AA)
name = img_path.split(".")[:-1]
name = ".".join(name)
cv2.imwrite(name + "-out1.jpg", out)
mtline.getInfo(img,1,1,0.125)
cv2.imwrite(name + "cannypf.jpg", mtline.canny_edge)

Releases

No releases published

Packages

No packages published

Languages