zoukankan      html  css  js  c++  java
  • opencv图片右转函数

    因为需要将函数进行右转,发现opencv自带 的过于麻烦。自己写了个右转的。可以根据这个想法写出任何方向的

     1 //函数功能,右转图片
     2 IplImage* convertImage(IplImage* image)
     3 {
     4     CvSize size = cvGetSize(image);
     5     IplImage* ori_image = cvCreateImage(cvSize(size.width / 2, size.height / 2), image->depth, image->nChannels);
     6     IplImage* cvt_image = cvCreateImage(cvSize(size.height / 2, size.width / 2), image->depth, image->nChannels);
     7     cvResize(image, ori_image);
     8     int x, y, w;
     9     for (y = ori_image->height; y >= 0; y--)
    10     {
    11         uchar* oriptr = (uchar*)(ori_image->imageData + y*ori_image->widthStep);
    12         for (x = 0; x < ori_image->width; x++)
    13         {
    14             uchar* curptr = (uchar*)(cvt_image->imageData + x*cvt_image->widthStep);
    15             curptr[3 * y] = oriptr[3 * x];
    16             curptr[3 * y + 1] = oriptr[3 * x + 1];
    17             curptr[3 * y + 2] = oriptr[3 * x + 2];
    18         }
    19     }
    20     cvReleaseImage(&image);
    21     cvReleaseImage(&ori_image);
    22     return cvt_image;
    23 }
  • 相关阅读:
    继承作业0920
    类与对象
    类和对象基础题
    类和对象数组
    数组
    字符串
    2.1面向对象
    7.1 Java集合概述
    Java动态代理的两种实现方法
    18.5.2动态代理和AOP
  • 原文地址:https://www.cnblogs.com/sytu/p/4472718.html
Copyright © 2011-2022 走看看