cv2画圈写字保存图像
画圈
Syntax: cv2.circle(image, center_coordinates, radius, color, thickness)
Parameters:
image: It is the image on which circle is to be drawn.
center_coordinates: It is the center coordinates of circle. The coordinates are represented as tuples of two values i.e. (X coordinate value, Y coordinate value).
radius: It is the radius of circle.
color: It is the color of border line of circle to be drawn. For BGR, we pass a tuple. eg: (255, 0, 0) for blue color.
thickness: It is the thickness of the circle border line in px. Thickness of -1 px will fill the circle shape by the specified color.
Return Value: It returns an image.
# Python program to explain cv2.circle() method# importing cv2
import cv2# path
path = r'C:\Users\Rajnish\Desktop\geeksforgeeks\geeks.png'# Reading an image in default mode
image = cv2.imread(path)# Window name in which image is displayed
window_name = 'Image'# Center coordinates
center_coordinates = (120, 50) # w h# Radius of circle
radius = 20# Blue color in BGR
color = (255, 0, 0)# Line thickness of 2 px
thickness = 2# Using cv2.circle() method
# Draw a circle with blue line borders of thickness of 2 px
image = cv2.circle(image, center_coordinates, radius, color, thickness)# Displaying the image
cv2.imshow(window_name, image)
写字
Syntax: cv2.putText(image, text, org, font, fontScale, color[, thickness[, lineType[, bottomLeftOrigin]]])Parameters:
image: It is the image on which text is to be drawn.
text: Text string to be drawn.
org: It is the coordinates of the bottom-left corner of the text string in the image. The coordinates are represented as tuples of two values i.e. (X coordinate value, Y coordinate value).
font: It denotes the font type. Some of font types are FONT_HERSHEY_SIMPLEX, FONT_HERSHEY_PLAIN, , etc.
fontScale: Font scale factor that is multiplied by the font-specific base size.
color: It is the color of text string to be drawn. For BGR, we pass a tuple. eg: (255, 0, 0) for blue color.
thickness: It is the thickness of the line in px.
lineType: This is an optional parameter.It gives the type of the line to be used.
bottomLeftOrigin: This is an optional parameter. When it is true, the image data origin is at the bottom-left corner. Otherwise, it is at the top-left corner.Return Value: It returns an image.
# Python program to explain cv2.putText() method# importing cv2
import cv2# path
path = r'C:\Users\Rajnish\Desktop\geeksforgeeks\geeks.png'# Reading an image in default mode
image = cv2.imread(path)# Window name in which image is displayed
window_name = 'Image'# font
font = cv2.FONT_HERSHEY_SIMPLEX# org
org = (50, 50)# fontScale
fontScale = 1# Blue color in BGR
color = (255, 0, 0)# Line thickness of 2 px
thickness = 2# Using cv2.putText() method
image = cv2.putText(image, 'OpenCV', org, font,fontScale, color, thickness, cv2.LINE_AA)# Displaying the image
cv2.imshow(window_name, image)
保存图像
import cv2# read image as grey scale
grey_img = cv2.imread('/home/img/python.png', cv2.IMREAD_GRAYSCALE)# save image
status = cv2.imwrite('/home/img/python_grey.png',grey_img)print("Image written to file-system : ",status)
ref
geeksforgeeks_cv2.circle()
geeksforgeeks_cv2.putText()
OpenCV Python Save Image – cv2.imwrite()
cv2画圈写字保存图像相关推荐
- 使用go语言画出sin函数图像
sin函数图像--go语言 步骤 创建底图对象 画sin图 保存图像到文件 图片展示 步骤 创建一张底色为白色的图片对象 画出sin图像 保存到文件中 创建底图对象 //设置图片尺寸 pir := i ...
- 【Python学习】 - 使用PIL, cv2, keras.preprocessing, scipy.imageio, matplotlib.image, skimage读取和保存图像的方法
python中图像处理相关库有很多,这里简单介绍PIL.cv2.scipy.imageio .matplotlib.image.skimage等常用库,其中PIL库使用最方便,cv2库功能最强大. P ...
- matlab中在图像上划线 画圈的方法
其实用plot都可以搞定. plot(imp(:,1),imp(:,2),'ro'); %最后的'ro',r是代表红色,o是代表画圈.画圈的话可以提供多个点的坐标,我这里用的就是向量的形式. plot ...
- python中怎样在图片上画线段_python 实现PIL模块在图片画线写字
图片上画线条 import sys from PIL import Image,ImageDraw im = Image.open("th.png") draw = ImageDr ...
- python怎么在图片上写字的软件_python 实现PIL模块在图片画线写字
图片上画线条 import sys from PIL import Image,ImageDraw im = Image.open("th.png") draw = ImageDr ...
- python写字_python 实现PIL模块在图片画线写字
图片上画线条 import sys from PIL import Image,ImageDraw im = Image.open("th.png") draw = ImageDr ...
- python画波浪线_python 实现PIL模块在图片画线写字
图片上画线条 import sys from PIL import Image,ImageDraw im = Image.open("th.png") draw = ImageDr ...
- 使用CV2和Keras OCR从图像中删除文本
点击上方"小白学视觉",选择加"星标"或"置顶" 重磅干货,第一时间送达 介绍 本文将讨论如何快速地从图像中删除文本,作为图像分类器的预处理 ...
- python的image读取的图片是什么类型的-opencv python 读取图像/显示图像/保存图像...
以前也用过opencv, 不过都是按需使用, 掌握的知识很零散, 这次希望能够系统学习opencv-python 本文直接从Gui Features开始. 1 读取图片 使用cv2.imread()函 ...
最新文章
- android源代码 abi,Android内核源码Abi目录学习笔记
- 关于DiscuzNT 1.0
- 正确解读free -m
- 佳能g3800故障灯说明书_佳能打印机故障如何维修 佳能打印机故障维修方法【介绍】...
- 放图片 java_java怎么在我想要的图片上在放一个我想要的图片
- mysql的两种存储方法_mysql的两种存储引擎
- ssm 跨库查询_SSM使用AbstractRoutingDataSource后究竟如何解决跨库事务
- ecshop 模板标签
- webservice远程调试开启
- 用Python写一个滑动验证码
- PHP kafka消息队列的使用
- 腾讯翻译君在线翻译怎么翻译整个文件_PDF文档如何直接翻译?有了这个逆天网站,3秒完成整个文件翻译...
- MeshLab学习笔记
- html5标签含义元素周期表
- repair table accessright
- 家用数码相机选购及使用指南
- 产品经理求职方法指南:面试通关
- python弧度制转换 三角函数 反三角函数 双曲 反双曲 sin cos tan asin acos atan asinh acosh atanh atanh2
- 统计学 计算机论文发表,数学科学学院博士生史册在统计学顶级期刊
《Annals of Statistics》上发表论文...
- 小学计算机课第二课堂活动,趣味课堂 童真飞扬 ——我校小学部开设丰富多彩的第二课堂...