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 |

相关推荐
7177776 小时前
国内 AI 研发效能工具怎么选:2026 年基于公开信息的选型框架与 Gitee 实践
人工智能·gitee
Csvn7 小时前
换供应商要改一遍代码?把模型接入收进一层网关(C04)
人工智能·aigc·agent
孟健7 小时前
开源AutoClip切直播:1小时48分出19段,整月API只花0.08元
人工智能·开源·aigc
翰墨之道7 小时前
AI日报:豆包工作ARR超20亿,GPT-6.2跑分与实测割裂
人工智能·gpt·数据挖掘
Maynor9968 小时前
Trymodel 使用介绍:一个平台同时用 Claude、GPT、Gemini 和 Grok
人工智能·gpt·ai·程序员·教程·claude·语音
字节跳动视频云技术团队9 小时前
接大模型别再自己配 Key、搭代理了,火山引擎 IGA Pages 一步搞定
人工智能
阿里云大数据AI技术9 小时前
EMR Serverless StarRocks 产品介绍:从统一 OLAP 走向多模态分析与检索
人工智能
Forget the Dream10 小时前
Spring AI 2.0 系列(二):第一个 ChatClient——从注入到一次完整调用
java·人工智能·spring boot·ai·springai
郝学胜-神的一滴10 小时前
Effective Python 条款35:用类封装替代生成器异常注入
开发语言·人工智能·python·金融·pandas·scikit-learn·matplotlib
火山引擎开发者社区10 小时前
豆包工作,3 个月,800 万,20 亿
人工智能