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 |

相关推荐
恋猫de小郭8 小时前
AI 可以让 WIFI 实现监控室内人体位置和姿态,无需摄像头?
前端·人工智能·ai编程
是一碗螺丝粉8 小时前
5分钟上手LangChain.js:用DeepSeek给你的App加上AI能力
前端·人工智能·langchain
两万五千个小时8 小时前
落地实现 Anthropic Multi-Agent Research System
人工智能·python·架构
用户4815930195918 小时前
揭秘GPT-4与LLaMA背后的加速黑科技:KV Cache、MQA、GQA、稀疏注意力与MoE全解析
人工智能
用户5191495848458 小时前
Cisco SMA 暴露面检测工具 - 快速识别CVE-2025-20393风险
人工智能·aigc
碳基沙盒8 小时前
AI工具的“超级外挂”:从零手把手教你搭建私人 MCP 服务器
人工智能
马腾化云东8 小时前
Agent开发应知应会(langfuse):Langfuse Score概念详解和实战应用
人工智能·llm·ai编程
Baihai_IDP8 小时前
HackerNews 热榜第一名:AGI 的 A,原来代表的是 Ads(广告)
人工智能·程序员·llm
ma_king8 小时前
claude+tmux 团队模式使用
人工智能·claude
CoovallyAIHub8 小时前
仿生学突破:SILD模型如何让无人机在电力线迷宫中发现“隐形威胁”
深度学习·算法·计算机视觉