OpenCV:超分辨率、超采样及测试性能

  • 代码

    import cv2
    import numpy as np
    import time

    def super_sample(file, scale, count):
    print
    print(file, scale, count)

    复制代码
      # 读取图像
      img = cv2.imread(file)
    
      start_time = time.time()
      for index in range(count):
          # 双三次插值
          bicubic = cv2.resize(img, None, fx=scale, fy=scale, interpolation=cv2.INTER_CUBIC)
      print('CUBIC cost time: %.2f ms' % ((time.time()-start_time)*1000/count))
      # cv2.imwrite('cv2-CUBIC.jpg', bicubic)
    
      start_time = time.time()
      for index in range(count):
          # Lanczos插值
          lanczos = cv2.resize(img, None, fx=scale, fy=scale, interpolation=cv2.INTER_LANCZOS4)
      print('LANCZOS4 cost time: %.2f ms' % ((time.time()-start_time)*1000/count))
      # cv2.imwrite('cv2-LANCZOS4.jpg', lanczos)

    count = 1000

    file1 = '1280x720.png'
    super_sample(file1, 2, count)
    super_sample(file1, 3, count)

    file2 = '1920x1080.png'
    super_sample(file2, 2, count)
    super_sample(file2, 3, count)

  • 测试结果

在虚拟机中测试的。

1280x720

|----------|-------|-------|
| | 2x2 | 3x3 |
| CUBIC | 2.14 | 3.83 |
| LANCZOS4 | 10.42 | 20.89 |

1920x1080

|----------|-------|-------|
| | 2x2 | 3x3 |
| CUBIC | 4.44 | 14.00 |
| LANCZOS4 | 24.24 | 50.56 |

相关推荐
腾科IT教育27 分钟前
Spring AI Alibaba 向量(VectorStore)
人工智能·spring·microsoft
IT_陈寒1 小时前
React中useEffect依赖项这个坑我居然踩了三天
前端·人工智能·后端
江畔柳前堤1 小时前
github实战指南02-仓库管理与 Issue
人工智能·深度学习·github·信号处理·caffe·wps·issue
邵宇然1 小时前
内存分配优化:基于 Unsafe 指针与内存对齐的 Rust 区域分配器
人工智能
海兰1 小时前
【游戏】迷雾镇(Mist Town)AI 沙箱游戏详细设计与部署指南(附源代码)
人工智能·游戏
小赖同学啊1 小时前
智能连接器集群化高可用生产方案
linux·运维·人工智能
ZStack开发者社区1 小时前
基于AI Agent的ZCF API文档全链路自动化
运维·人工智能·自动化
沈麽鬼1 小时前
别瞎用AI写代码!90%开发者都搞错了AI编程的底层逻辑
人工智能·ai编程·trae
小陈爱编程2 小时前
我终于把 Codex 的 API 配置理顺了:从踩坑到跑通
人工智能
不爱洗脚的小滕2 小时前
【Agent】如何为 AI Agent 设计高可用的 Tools
人工智能·aigc·ai编程·rag