zoukankan      html  css  js  c++  java
  • 3-4 图片缩放3

    # 1 info 2 空白模板 3 xy
    import cv2
    import numpy as np
    img = cv2.imread('image0.jpg',1)
    imgInfo = img.shape
    height = imgInfo[0]
    width = imgInfo[1]
    dstHeight = int(height/2)
    dstWidth = int(width/2)
    dstImage = np.zeros((dstHeight,dstWidth,3),np.uint8)#创建一个空白的模板,这个模板的大小我们这样来设置,它有两个参数
    #第一个参数我们给它一个图片的信息,比如说图片的宽度信息高度信息等
    # 3表明每一个像素是由三个基本颜色来进行组成
    # 0-255 同时还要设置一下每一个像素的数据类型 uint8的范围是0-255
    # 计算一下这个新的xy坐标
    for i in range(0,dstHeight):#
        for j in range(0,dstWidth):#
            iNew = int(i*(height*1.0/dstHeight))
            jNew = int(j*(width*1.0/dstWidth))
            dstImage[i,j]= img[iNew,jNew]
    cv2.imshow('dst',dstImage)
    cv2.waitKey(0)
    # 1 info 2 空白模板 3 xy
    import cv2
    import numpy as np
    img = cv2.imread('image0.jpg',1)
    imgInfo = img.shape
    height = imgInfo[0]
    width = imgInfo[1]
    dstHeight = int(height/2)
    dstWidth = int(width/2)
    dstImage = np.zeros((dstHeight,dstWidth,3),np.uint8)#创建一个空白的模板,这个模板的大小我们这样来设置,它有两个参数
    #第一个参数我们给它一个图片的信息,比如说图片的宽度信息高度信息等
    # 3表明每一个像素是由三个基本颜色来进行组成
    # 0-255 同时还要设置一下每一个像素的数据类型 uint8的范围是0-255
    # 计算一下这个新的xy坐标
    for i in range(0,dstHeight):#
        for j in range(0,dstWidth):#
            iNew = int(i*(height*1.0/dstHeight))
            jNew = int(j*(width*1.0/dstWidth))
            dstImage[i,j]= img[iNew,jNew]
    cv2.imshow('dst',dstImage)
    cv2.waitKey(0)
    # 1 opencv API resize 2 算法原理 3 源码
  • 相关阅读:
    .net core 3.1 添加区域 area
    JMeter 网站并发测试工具使用教程
    .net core 3.1 使用ado.net
    .net core 3.1 mvc 调试的时 更改cshtml页面 刷新浏览器不更新
    .net core 3.1 autofac(webapi / mvc 通过)
    .net core3.1 rest api 无法接收 vue 中 axios 请求
    .net core 3.1 web api 允许跨域
    mysql 中文匹配
    mysql 分组排序
    mysql json处理
  • 原文地址:https://www.cnblogs.com/ZHONGZHENHUA/p/9676757.html
Copyright © 2011-2022 走看看