zoukankan      html  css  js  c++  java
  • 图像移位

      

    import cv2
    import numpy as np
    
    img = cv2.imread('image0.jpg', 1)
    cv2.imshow('src', img)
    
    imgInfo = img.shape
    height = imgInfo[0]
    width = imgInfo[1]
    
    matShift = np.float32([[1, 0, 100], [0, 1, 200]]) # 2*3
    dst = cv2.warpAffine(img, matShift, (height, width))
    # 原始图片data信息, 移位矩阵, 图片的info信息
    # 移位 矩阵
    cv2.imshow('dst', dst)
    cv2.waitKey(0)
    

      

    # API 移位原理
    # [1, 0, 100], [0, 1, 200] 2*2 2*1
    # [[1, 0], [0, 1]] 2*2 A
    # [[100], [200]] 2*1 B
    # [[x], [y]] C 2*1
    # A*C + B = [[1*x+0*y],[0*x+1*y]] + [[100], [200]]
    # = [[x+100], [y+200]]

    # (10, 20) -> (110, 120)

    import cv2
    import numpy as np
    
    img = cv2.imread('image0.jpg', 1)
    cv2.imshow('src', img)
    imgInfo = img.shape
    dst = np.zeros(img.shape, np.uint8)
    height = imgInfo[0]
    width = imgInfo[1]
    for i in range(0, height):
        for j in range(0, width-100):
            dst[i, j+100] = img[i, j]
    
    cv2.imshow('image', dst)
    cv2.waitKey(0)
    

      

  • 相关阅读:
    Angular 中使用第三方模块 axios 请求数据
    angular 创建服务
    Promise和RxJS处理异步对比
    ES6中的迭代器(Iterator)和生成器(Generator)
    async await
    Ajax分析
    JSTL
    EL
    Spring-常用依赖及配置
    Spring-AOP的三种方式
  • 原文地址:https://www.cnblogs.com/mjn1/p/11215704.html
Copyright © 2011-2022 走看看