文章目录
前言
本程序主要应用于栅格图像的处理,采用递归思想实现种子填充算法。
一、算法实现
# -*- coding = utf-8 -*-
# @time:2021/5/25 23:33
# Author:scw
# @File:Seed_Filling.py
# @Software:PyCharm
# Environment:Python3.6
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.cm as cm
import sys
# 更改递归深度
sys.setrecursionlimit(100000)
class Seed_Filling_S(object):
def __init__(self):
self.wide = None
self.height = None
self.photolist = []
self.queue = []
self.area_limit = 40
self.char = 1
self.label = 0
# 读取文本数据并预处理