Problems
Contests
Events
Standings
Topic
IDE
Login
Topic
New Topic
Python + openCV去除图片中红色字体
HappyOJ
post at
5 months ago
13876
1
0
```python import cv2 import numpy as np class SealRemove(object): def remove_red_seal(self, image): # 获得红色通道 blue_c, green_c, red_c = cv2.split(image) # 多传入一个参数cv2.THRESH_OTSU,并且把阈值thresh设为0,算法会找到最优阈值 thresh, ret = cv2.threshold(red_c, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU) # 实测调整为95%效果好一些 filter_condition = int(thresh * 0.95) nominator_thresh, red_thresh = cv2.threshold(red_c, filter_condition, 255, cv2.THRESH_BINARY) return red_thresh def shijuanqingli(self, image): thresh, dst1 = cv2.threshold(image, 50, 255, cv2.THRESH_BINARY) dst1_without_pen = dst1 return dst1_without_pen def join_image(self, img_without_red, dst1_without_pen): ret = cv2.bitwise_or(img_without_red, dst1_without_pen) return ret if __name__ == '__main__': src = r'mask/dehw_train_00471.jpg' image0 = cv2.imread(src) seal_rm = SealRemove() image_0 = seal_rm.remove_red_seal(image0) # image_0_1 = cv2.cvtColor(image_0, cv2.COLOR_BGR2GRAY) image1 = cv2.imread(src, 0) #image_1 = seal_rm.shijuanqingli(image1) image_result = seal_rm.join_image(image_0, image1) cv2.imshow('new image', image_result) cv2.waitKey(0) cv2.destroyAllWindows() src_temp = src.split(r'.') src_result = src_temp[0] + '_new.' + src_temp[1] cv2.imwrite(src_result,image_result) ```
Reply Topic
Twitter
Comments ( 1 )
Weizengke
post at1 months ago
0
效果不错
Hot Tags
dfs
22
implementation
19
dp
15
蓝桥
14
string
11
math
11
big number
10
number theory
9
combinatorics
9
happyoj
5
springboot
4
brute force
4
javascript
3
bfs
3
greedy
3
如梦令
3
divide and conquer
2
linux
2
Copilot
2
graph
2
probabilities
2
sortings
2
data structures
2
xor
2
python
1
telnetlib
1
cron
1
题解
1
docker
1
https
1
→
Top10
南柯
2023
cxlove
1970
vainner
1763
4
1000310428赵成帅
1718
5
XiaoWen
1710
6
1000380213洪伟焕
1701
7
weiben
1684
8
Jungle.Wei
1678
9
1100310131曾翔宇
1664
10
hongwh
1653
→
Topics
vbox Ubuntu无界面动态扩展磁盘空间
###问题:磁盘创建时时动态扩展方式,现在空间已经不足,却没有自动扩展生效磁盘空间
Problem A + B
略微有单简单
python 使用telnetlib登陆telnet服务器
```python
你好,请问如何在Windows下架设WEB?
大大你好,我是一个小白。
Python + openCV去除图片中红色字体
Github Copilot在代码检视内存泄漏上的能力
## 我给了一个带出参的由内存申请的函数,它能够识别函数内没有泄漏,但是需要提醒我调用者有没有释放内存,还是不错。
使用Github Copilot辅助开发的一些感受
## 我先选择了一段比较简单的代码,发现它给出的解释实际上就是代码本身自注释到的
Ubuntu 如何安装HappyOJ
## Table of contents
@Scheduled注解实现启动时延时60秒执行一次定时任务,后续按照cron定义的计划执行
最近遇到一个问题,通过springboot Scheduled定时调度,在启动时就会执行定时任务,导致启动性能较差。
【JS】JS设置粘贴板内容的方法
方法1:
→