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 |

相关推荐
镜象科技2 小时前
AI情感大模型应用场景全解:从校园到医院再到企业的落地地图
人工智能
Joshua-a2 小时前
工程数学-理解卷积的含义_线性时不变系统的冲激响应与卷积
人工智能·深度学习
song5012 小时前
React Native for OpenHarmony 实战:三方库 react-native-css-transformer 的鸿蒙化适配指南
css·人工智能·深度学习·react native·transformer
老金带你玩AI7 小时前
ChatGPT dots,到底能替你操多少心?
人工智能
AliCloudROS8 小时前
计算巢 X DeepSeek Harness — 云端智能体工作台
人工智能·阿里云
深蓝AI8 小时前
GitHub的Push一年涨4.9倍:AI Agent为什么逼它重做Git存储?
人工智能·github
stereohomology8 小时前
大模型的观点谨:StoryTold 「Crafting Apps」四件套 · 深度总览
人工智能·llm
运维行者_8 小时前
网络性能监控怎么做?从自动发现到根因分析的4个环节
运维·服务器·网络·人工智能·支持向量机
Su米苏9 小时前
Spring AI 中MCP 与普通 @Tool的区别
java·人工智能·spring
美狐美颜sdk9 小时前
直播APP源码可以直接接入视频美颜sdk吗?技术方案详解
android·人工智能·音视频·美颜sdk·直播美颜sdk