import sys from PIL import Image,ImageDraw im = Image.open("th.png") draw = ImageDraw.Draw(im) #实例化一个对象 draw.line...((0, 0) + im.size, fill=128, width=5) #线的起点和终点,线宽 draw.line((0, im.size[1], im.size[0], 0), fill=128)...draw.line((0,im.size[1]/2)+(im.size[0]/2,im.size[1]), fill=128, width=5) im.show() 图片上写字 from PIL import
skimage.draw.line(r1,c1,r2,c2) r1,r2: 开始点的行数和结束点的行数 c1,c2: 开始点的列数和结束点的列数 返回当前绘制图形上所有点的坐标,如: rr, cc =draw.line...返回线上所有的像素点坐标[rr,cc] from skimage import draw,data import matplotlib.pyplot as plt img=data.chelsea() rr, cc =draw.line...from skimage import draw,data import matplotlib.pyplot as plt img=data.chelsea() rr, cc =draw.line(1,
import Image, ImageDraw im = Image.open(r'C:\Users\xpp\Desktop\lena.jpg') draw = ImageDraw.Draw(im) draw.line...((0, 0) + im.size, fill=128,width=5) draw.line((0, im.size[1], im.size[0], 0), fill=128,width=5) im.show...import Image, ImageDraw im = Image.open(r'C:\Users\xpp\Desktop\lena.jpg') draw = ImageDraw.Draw(im) draw.line...((0, 0) + im.size, fill=128,width=5) draw.line((0, im.size[1], im.size[0], 0), fill=128,width=5) im.show
= everage_line * j start = (everage_line, 0) end = (everage_line, size[1]) draw.line...= everage_line * j start = (everage_line, 0) end = (everage_line, size[1]) draw.line...= everage_line * i start = (0, everage_line) end = (size[0], everage_line) draw.line...x_zuobiao = x_zuobiao*x start = (x_zuobiao, 0) end = (x_zuobiao, h) draw.line...y_zuobiao = y_zuobiao * y start = (0, y_zuobiao) end = (w, y_zuobiao) draw.line
ImageDraw.Draw(image)ImageDraw类给我们提供了丰富的选择,支持我们绘制圆弧,饼图,折线图,矩形图,多边形等方法,下面我们来一一介绍:绘制线形图我们可以绘制直线和折线图,代码如下:draw.line...((50, 50, 100, 150), fill='green', width=6)draw.line((50, 200, 75, 300, 100, 250, 75, 200), fill='red
=np.zeros((400,400)) image[10:-10,10:100]=1 image[-100:-10,10:-10]=1 image[10:-10,-100:-10]=1 rs,cs=draw.line...(250,150,10,280) for i in range(10): image[rs+i,cs]=1 rs, cs = draw.line(10, 150, 250, 280) for i in
width), random.randint(0, height)) end = (random.randint(0, width), random.randint(0, height)) draw.line...width), random.randint(0, height)) end = (random.randint(0, width), random.randint(0, height)) draw.line
ImageDraw im01 =Image.open("D:\Code\Python\test\img\test01.jpg") draw =ImageDraw.Draw(im01) draw.line...((0,0) +im01.size, fill=128) draw.line((0,im01.size[1], im.size[0], 0), fill = 128) im01.show...5、 Line 定义:draw.line(xy,options) 含义:在变量xy列表所表示的坐标之间画线。 坐标列表可以是任何包含2元组[(x,y),…]或者数字[x,y,…]的序列对象。...ImageDraw im01 = Image.open("D:\Code\Python\test\img\test01.jpg") draw = ImageDraw.Draw(im01) draw.line...([(0,0),(100,300),(200,500)], fill = (255,0,0), width = 5) draw.line([50,10,100,200,400,300], fill
[x1,x2,y1,y2]或者[(x1,x2),(y1,y2)] fill代表的为颜色 draw.line([100,100,100,600],fill='pink')#直线 draw.line([100,100,600,100...],fill='green') draw.line([600,100,600,600],'black') draw.line([100,600,600,600],'blue') # 弧形 [x1,
print(im.size) draw = ImageDraw.Draw(im) #元组相加等于一个合并的元组,这里设置划线的起始坐标和重点坐标, 注意x坐标是向下跑的 fill里面设置RGBA的值 draw.line...(((0, 0) + im.size), fill=(340,83,45),width=10) draw.line((0, im.size[1], im.size[0], 0), fill=128) del
30), color=(255, 255, 255)) draw = ImageDraw.Draw(img, mode='RGB') # 第一个参数:表示起始坐标和结束坐标 # 第二个参数:表示颜色 draw.line...((100,100,100,300), fill='red') draw.line((100,100,300,100), fill=(255, 255, 255)) 5. ...(0, height) x2 = random.randint(0, width) y2 = random.randint(0, height) draw.line...random.randint(0, 40) x2 = random.randint(0, 120) y2 = random.randint(0, 40) draw.line
start = (0, random.randint(0, size[1]-1)) end = (size[0], random.randint(0, size[1]-1)) draw.line
画图的方法介绍 方法 示范 作用 ImageDraw.line(xy, fill=None, width=0, joint=None) draw.line([100, 100, 100, 500], fill...# 画点 im = Image.new('RGB', (600, 600), 'white') draw = ImageDraw.Draw(im) # # 创建一个正方形,fill 代表的为颜色 draw.line...([100, 100, 100, 500], fill='blue', width=2) # 左竖线 draw.line([100, 100, 500, 100], fill='blue', width...=2) # 上横线 draw.line([500, 100, 500, 500], 'blue', width=2) #右竖线 draw.line([100, 500, 500, 500], 'blue
03 创建画笔 draw = ImageDraw.Draw(img) 04 绘制线条和点 绘制线条 for i in range(random.randint(1,10)): draw.line...(1,150),random.randint(1,150)) ], fill = (0,0,0) ) 这里random.randint(1,10)函数用来生成1-10之间的随机数,draw.line
, quality=95) 创建512x512大小,蓝色图像 im = Image.new("RGB", (512, 512), (0, 0, 255)) im.show() 填充直线、长方形与椭圆 draw.line
:, :, 2] = 100 image = Image.fromarray(array) #创建绘制对象 draw = ImageDraw.Draw(image) #绘制直线 draw.line...((100, 50), u'Hello World', 'fuchsia', font) image.show() return 首先,通过ImageDraw类创建一个绘制对象draw; draw.line
(left + width, top + height), (left , top + height), (left, top)) draw.line...(x2, y2), (x1 , y2), (x1, y1) ) draw.line
def randLine(self, num): draw = ImageDraw.Draw(self.image) for i in range(0, num): draw.line
range(5): start = (0, randrange(size[1])) end = (size[0], randrange(size[1])) draw.line
random.randint(0,width) x2 = random.randint(0,width) y1 = random.randint(0,height) y2 = random.randint(0,height) draw.line
领取专属 10元无门槛券
手把手带您无忧上云