提交 c9c8dc62 编写于 作者: F feilong

fix png

上级 59823dfe
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
OpenCV 里的连通区域分析可以将具有相同像素值且位置相邻的前景像素点组成的图像区域识别出来。有两种像素相邻的定义: OpenCV 里的连通区域分析可以将具有相同像素值且位置相邻的前景像素点组成的图像区域识别出来。有两种像素相邻的定义:
![](./pixel_region.jpg) ![](data/1.OpenCV初阶/2.二值图像处理/4.连通区域分析/pixel_region.jpg)
通过OpenCV的连通区域分析算法,我们可以将下图的水鸭子的外框框出来: 通过OpenCV的连通区域分析算法,我们可以将下图的水鸭子的外框框出来:
![](./duck_box.png) ![](data/1.OpenCV初阶/2.二值图像处理/4.连通区域分析/duck_box.png)
框架代码如下: 框架代码如下:
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from src.tree import TreeWalker from src.tree import TreeWalker
from src.doc import DocWalker from src.doc import DocWalker
from src.img import ImgWalker
if __name__ == '__main__': if __name__ == '__main__':
walker = TreeWalker("data", "opencv", "OpenCV") # walker = TreeWalker("data", "opencv", "OpenCV")
walker.walk() # walker.walk()
doc = DocWalker('doc') # doc = DocWalker('doc')
doc.walk() # doc.walk()
img = ImgWalker('data')
img.walk()
import os
from sys import path, version
from types import new_class
from .tree import load_json, dump_json
def simple_list_md_load(p):
with open(p, 'r', encoding='utf-8') as f:
lines = f.readlines()
result = []
for line in lines:
item = line.strip('\n')
result.append(item)
return result
def simple_list_md_dump(p, lines):
with open(p, 'w', encoding='utf-8') as f:
f.write('\n'.join(lines))
class ImgWalker():
def __init__(self, root) -> None:
self.root = root
def walk(self):
for base, dirs, files in os.walk(self.root):
for file in files:
if file[-3:] == '.md':
md_file = os.path.join(base, file)
md_lines = simple_list_md_load(md_file)
md_new = []
for line in md_lines:
new_line = line.replace('![](./', f'![]({base}/')
md_new.append(new_line)
md_new.append('')
simple_list_md_dump(md_file, md_new)
import sys
sys.exit(0)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册