# -*- coding: utf-8 -*-

import turtle as t
import cv2 def draw_img(img_path, scale=1):
"""
画图片里的内容
:param img_path: 图片路径
:param scale: 缩放比例,比如1,0.5,0.25
:return:
"""
t.getscreen().colormode(255)
img = cv2.imread(img_path)
img1 = img[::int(1/scale)] # 取图片一半(隔行取)的行数据
width = len(img1[0])/int(1/scale) # 取图片的宽度
height = len(img1) # 取图片的高度 t.setup(width=width+100, height=height+100) # 设置画布大小, 600, 370
t.pu()
t.goto(-width/2 + 10, height/2 - 10) # 移动到指定坐标的位置 -140,
t.pd()
t.tracer(3000) # 加快作图速度, 0 or False 时图形一次性画好 for k1, i in enumerate(img1):
for j in i[::int(1/scale)]:
t.pencolor((j[2], j[1], j[0])) # 设置画笔颜色
t.fd(1) # 沿着海龟的前方向运行1
t.pu() # 画笔抬起,不留下痕迹
t.goto(-width/2, height/2 -k1) # 移动画笔到下一行最左侧位置
t.pd() # 画笔落下,留下痕迹
t.done() if __name__ == '__main__':
path = r'./2.jpg'
draw_img(path, 0.5)

最新文章

  1. Mysql 主从热备份
  2. SVN使用教程
  3. Android 网络图片查看器
  4. IOS8下,百度地图无法定位解决办法
  5. drawer principle in Combinatorics
  6. Window nginx+tomcat+https部署方案 支持ios9
  7. Oracle 动态视图3 V$SESSION
  8. avconv转换视频
  9. jQuery Mobile 图标无法显示
  10. C# 多线程详解
  11. Java BufferedReader、InputStream简介
  12. js引用类型数组去重-对象标记法
  13. 二 Djano模型层之模型字段选项
  14. Activiti6-TaskService(学习笔记)重要
  15. rsync同步时,删除目标目录比源目录多余文件的方法(--delete)
  16. (1.4)mysql sql mode 设置与使用
  17. java 异步机制与同步机制的区别
  18. VS2008 试图运行未注册64位调试器组件
  19. Minicap使用分析
  20. Python3.x获取网页源码

热门文章

  1. react hooks组件父组件调用子组件方法
  2. Java——四种线程创建方式
  3. windows用curl报错
  4. Delphi 新语法:匿名函数
  5. MyBatisPlus 报MP_OPTLOCK_VERSION_ORIGINAL not found. Available parameters are错误
  6. [MySQL高级](一) EXPLAIN用法和结果分析
  7. Dell CS24-SC 服务器详情
  8. 大道至简读后感以及JAVA伪代码
  9. 有null值的子查询,子查询加排序,速度大幅提升
  10. SpringBoot配置阿里云https提示端口占用问题