1. // image_pyramid.cpp : 定义控制台应用程序的入口点。
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <string>
  6. #include <iostream>
  7. using namespace std;
  8.  
  9. #include "opencv2/imgproc/imgproc.hpp"
  10. #include "opencv2/highgui/highgui.hpp"
  11. #include <math.h>
  12. #include <stdlib.h>
  13. #include <stdio.h>
  14.  
  15. #pragma comment(lib,"opencv_core2410d.lib")
  16. #pragma comment(lib,"opencv_highgui2410d.lib")
  17. #pragma comment(lib,"opencv_imgproc2410d.lib")
  18.  
  19. using namespace cv;
  20.  
  21. /// 全局变量
  22. Mat src, dst, tmp;
  23. char* window_name = "Pyramids Demo";
  24.  
  25. /**
  26. * @函数 main
  27. */
  28. int main( int argc, char** argv )
  29. {
  30. /// 指示说明
  31. printf( "\n Zoom In-Out demo \n " );
  32. printf( "------------------ \n" );
  33. printf( " * [u] -> Zoom in \n" );
  34. printf( " * [d] -> Zoom out \n" );
  35. printf( " * [ESC] -> Close program \n \n" );
  36.  
  37. /// 测试图像 - 尺寸必须能被 2^{n} 整除
  38. string image_name;
  39. cout<<"input image name:"<<endl;
  40. cin>>image_name;
  41.  
  42. src = imread( image_name);
  43. if( !src.data )
  44. { printf(" No data! -- Exiting the program \n");
  45. return -1; }
  46.  
  47. tmp = src;
  48. dst = tmp;
  49.  
  50. /// 创建显示窗口
  51. namedWindow( window_name, CV_WINDOW_AUTOSIZE );
  52. imshow( window_name, dst );
  53.  
  54. /// 循环
  55. while( true )
  56. {
  57. int c;
  58. c = waitKey(10);
  59.  
  60. if( (char)c == 27 )
  61. { break; }
  62. if( (char)c == 'u' )
  63. { pyrUp( tmp, dst, Size( tmp.cols*2, tmp.rows*2 ) );
  64. printf( "** Zoom In: Image x 2 \n" );
  65. }
  66. else if( (char)c == 'd' )
  67. { pyrDown( tmp, dst, Size( tmp.cols/2, tmp.rows/2 ) );
  68. printf( "** Zoom Out: Image / 2 \n" );
  69. }
  70.  
  71. imshow( window_name, dst );
  72. tmp = dst;
  73. }
  74. return 0;
  75. }
  76.  
  77. //缩小,再放大就模糊了,什么情况?

OpenCV 金字塔图像缩放的更多相关文章

  1. python+opencv实现图像缩放

    x, y = img_.shape[0:2] img_ = cv2.resize(img_, (int(y/2), int(x/2))) 实现图像长宽缩小为原来的一半

  2. 使用OpenCV对图像进行缩放

    OpenCV:图片缩放和图像金字塔 对图像进行缩放的最简单方法当然是调用resize函数啦! resize函数可以将源图像精确地转化为指定尺寸的目标图像. 要缩小图像,一般推荐使用CV_INETR_A ...

  3. opencv学习笔记——图像缩放函数resize

    opencv提供了一种图像缩放函数 功能:实现对输入图像缩放到指定大小 函数原型: void cv::resize ( InputArray src, OutputArray dst, Size ds ...

  4. OpenCV计算机视觉学习(11)——图像空间几何变换(图像缩放,图像旋转,图像翻转,图像平移,仿射变换,镜像变换)

    如果需要处理的原图及代码,请移步小编的GitHub地址 传送门:请点击我 如果点击有误:https://github.com/LeBron-Jian/ComputerVisionPractice 图像 ...

  5. 图像缩放_OpenCv

    图像缩放是一种比较简单的图像处理操作,这里给出opencv中的代码, opencv的版本C语言接口 int resize_c() { const char *pstrImageName = " ...

  6. opencv2 矩阵方式 resize图像缩放代码(转载)

    http://blog.sina.com.cn/s/blog_74a459380101r0yx.html opencv2 矩阵方式 resize图像缩放代码(转载) (2014-05-16 09:55 ...

  7. opencv3 图像处理(一)图像缩放( python与c++ 实现)

    opencv3 图像处理 之 图像缩放( python与c++实现 ) 一. 主要函数介绍 1) 图像大小变换 Resize () 原型: void Resize(const CvArr* src,C ...

  8. 邻近双线性插值图像缩放的Python实现

    最近在查找有关图像缩放之类的算法,因工作中需要用到诸如此类的图像处理算法就在网上了解了一下相关算法,以及其原理,并用Python实现,且亲自验证过,在次与大家分享. 声明:本文代码示例针对的是plan ...

  9. c#数字图像处理(十)图像缩放

    图像几何变换(缩放.旋转)中的常用的插值算法 在图像几何变换的过程中,常用的插值方法有最邻近插值(近邻取样法).双线性内插值和三次卷积法. 最邻近插值: 这是一种最为简单的插值方法,在图像中最小的单位 ...

随机推荐

  1. Python Generator 运行细节验证

    今天来__next__和send, 改天来throw和close class A: def __setattr__(self, key, val): print('set %s to %s'%(key ...

  2. Python descriptor

    class A: def __init__(self, name): self.name = name def __get__(self, ins, cls): print('call get') i ...

  3. Linux 高性能服务器编程——Linux服务器程序规范

    问题聚焦:     除了网络通信外,服务器程序通常还必须考虑许多其他细节问题,这些细节问题涉及面逛且零碎,而且基本上是模板式的,所以称之为服务器程序规范.     工欲善其事,必先利其器,这篇主要来探 ...

  4. Oracle EBS各个模块日志收集的方法

    MSCA(Mobile Supply Chain Application)日志的收集 Reference Note:338291.1 - Howto Enable WMS / MSCA Logging ...

  5. Android简易实战教程--第二十九话《创建图片副本》

    承接第二十八话加载大图片,本篇介绍如何创建一个图片的副本. 安卓中加载的原图是无法对其修改的,因为默认权限是只读的.但是通过创建副本,就可以对其做一些修改,绘制等了. 首先创建一个简单的布局.一个放原 ...

  6. 4.QPixmap,QTransform,绘图函数的使用

     新建一个项目Painter MyWidget.h #ifndef MYWIDGET_H #define MYWIDGET_H #include <QWidget> class MyW ...

  7. TCP连接建立系列 — 客户端发送SYN段

    主要内容:客户端调用connect()时的TCP层实现. 内核版本:3.15.2 我的博客:http://blog.csdn.net/zhangskd connect的TCP层实现 SOCK_STRE ...

  8. Linux上程序调试的基石(2)--GDB

    3. GDB的实现 GDB是GNU发布的一个强大的程序调试工具,用以调试C/C++程序.可以使程序员在程序运行的时候观察程序在内存/寄存器中的使用情况.它的实现也是基于ptrace系统调用来完成的.  ...

  9. 02_NoSQL数据库之Redis数据库:string类型和hash类型

     Strings类型及操作 String是最简单的类型,一个key对应一个Value,String类型是二进制安全的.Redis的String可以包含任何数据,比如jpg图片或者序列化的对象. S ...

  10. ProgressBar的indeterminateDrawable属性在安卓6.0上的问题

    通过indeterminateDrawable属性去自定义ProgressBar方法: <ProgressBar android:id="@+id/pb" android:l ...