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 |

相关推荐
shishi5212 小时前
trae重装后,无法预览调试弹窗报错的解决方案
ide·计算机视觉·语言模型
梁下轻语的秋缘3 小时前
Prompt工程核心指南:从入门到精通,让AI精准响应你的需求
大数据·人工智能·prompt
FreeBuf_3 小时前
ChatGPT引用马斯克AI生成的Grokipedia是否陷入“内容陷阱“?
人工智能·chatgpt
福客AI智能客服3 小时前
工单智转:电商智能客服与客服AI系统重构售后服务效率
大数据·人工智能
逄逄不是胖胖3 小时前
《动手学深度学习》-54循环神经网络RNN
人工智能·深度学习
AIGC合规助手4 小时前
AI智能硬件I万亿市场预测+算法、大模型备案合规手册
大数据·人工智能·智能硬件
物联网APP开发从业者4 小时前
2026年AI智能硬件集成开发十大平台技术场景深度解析
人工智能·智能硬件
玄同7654 小时前
LangChain 核心组件全解析:构建大模型应用的 “乐高积木”
人工智能·python·语言模型·langchain·llm·nlp·知识图谱
雨中飘荡的记忆4 小时前
Spring AI Gateway:从入门到实战,打造智能AI服务网关
人工智能·spring·gateway