GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Captcha-Segmentation/Repair.py at master · 102757017/Captcha-Segmentation

Expand file tree

/

Repair.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
35 lines (27 loc) · 1023 Bytes
/

Repair.py

Copy path

File metadata and controls

35 lines (27 loc) · 1023 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# -*- coding: UTF-8 -*-
import numpy as np
from PIL import Image
import os
import cv2
def repair(frame):
# 把 BGR 转为 HSV
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
# opencv中,H(色度)范围[0,255],S(饱和度)范围[0,255],V(亮度)范围[0,115]
lower_blue = np.array([0, 0, 0])
upper_blue = np.array([255, 255, 115])
# 获得区域的mask
mask = cv2.inRange(hsv, lower_blue, upper_blue)
h_structure = cv2.getStructuringElement(cv2.MORPH_RECT, (3, 1))
# 膨胀mask
mask = cv2.dilate(mask, h_structure, 1)
cv2.imwrite("mask.jpg", mask)
dst = cv2.inpaint(frame, mask, 5, cv2.INPAINT_TELEA)
#cv2.namedWindow('mask', cv2.WINDOW_NORMAL)
#cv2.imshow('mask', dst)
cv2.imwrite("binary.png", dst)
return dst
if __name__=="__main__":
os.chdir(os.path.dirname(__file__))
# 由于opencv不支持读取中文路径,用以下方法代替cv2.imread
frame = cv2.imdecode(np.fromfile('binary3.png', dtype=np.uint8), 1)
repair(frame)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.