一个练习的代码,先对图片进行缩放,然后再做镜像:

import cv2
import numpy as np img = cv2.imread("src.jpg", 1)
cv2.imshow("src",img) imgInfo = img.shape
height = imgInfo[0]
width  = imgInfo[1]
deep   =  imgInfo[2] #图片大,镜像后太高屏幕显示不全,这里先缩放
matScale = np.float32([[0.8,0,0], [0,0.8,0]])
scale = cv2.warpAffine(img, matScale, (int(width*0.8), int(height*0.8)))   cv2.imshow("scale", scale) #重新获取缩放后的图片高与宽
imgInfo = scale.shape
height  = imgInfo[0]
width   = imgInfo[1] #镜像的图片信息
newImgInfo = (height * 2, width, deep)
dest = np.zeros(newImgInfo, np.uint8) #镜像
for i in range(0, height):
    for j in range(0, width):
        dest[i,j] = scale[i,j]
        dest[height*2 - i -1, j] = scale[i, j] #画一个镜像与原图分割线        
for i in range(0, width):
    dest[height, i] = (0,0,255) cv2.imshow("dst", dest)
cv2.waitKey(0)

三张图片效果如下:

最新文章

  1. DIV+CSS布局网站基本框架
  2. 2076 Problem F Quick Brown Fox
  3. asp.net截取指定长度的字符串内容
  4. 安卓应用运营知识:VersionCode和VersionName
  5. android ping网络是否成功
  6. 【转载】干货来袭!Linux小白最佳实践:《超容易的Linux系统管理入门书》(连载七)LAMP集成安装
  7. 关于Mysql Can't connect to mysql server on localhost(10061)的问题解决
  8. Ubuntu系列Crontab日记记录
  9. 转载:struts标签<s:date>的使用
  10. start.sh
  11. C++ #if #endif #define #ifdef #ifndef #if defined #if !defined详解 (转)
  12. php的函数参数按照从左到右来赋值
  13. leetcode — sqrtx
  14. jquery实现全选 反选 取消
  15. 洛谷P1044 栈
  16. 一块移动硬盘怎样兼容Mac和Windows系统,并且可以在time machine上使用
  17. 转-Asynchronous bulk transfer using libusb
  18. JS 原型链 prototypt 和隐式原型 _proto_
  19. JavaScript DOM 元素属性 状态属性
  20. 在JS数组指定位置插入元素

热门文章

  1. Flask-Limit使用详细说明
  2. java 基本语法(十三) 数组(六)数组的常见异常
  3. 数据可视化实例(三): 散点图(pandas,matplotlib,numpy)
  4. day5 python代码块,流程控制
  5. Cyber Security - Palo Alto Security Policies(2)
  6. Dresdon二次开发
  7. cmd : 代理设置/检验代理设置成功
  8. CodeForces - 722C Destroying Array (并查集/集合的插入和删除)
  9. 解决win10安装flask-mysqldb报错 Python2.7
  10. C++11 STL Regex正则表达式与字符串字段解析