zoukankan      html  css  js  c++  java
  • 【学习opencv第六篇】图像的反转操作

    考试终于完了,现在终于有时间可以继续学习这个了。写这篇博客主要是因为以前一直搞不清楚图像数据到底是怎么存储的,以及这个step到底是什么,后来查了一下才知道原来step就是数据行的长度。。

    #include "stdafx.h"
    #include <highgui.h>
    #include <math.h>
    #include <cv.h>
    using namespace std;
    int main()
    {
    	IplImage* sourceImage;     
    	sourceImage= cvLoadImage("Hough.jpg",0);   
    	/*以灰度图像读入	*/
    	if(!sourceImage)
    		return -1;
    	//cout<<"successfully"<<endl;
    	cvNamedWindow("sourceImage",0);
    	cvShowImage("sourceImage",sourceImage);
    	char* data;
    	int step= sourceImage->widthStep;
    	int channels = sourceImage->nChannels;
    	data = (char*)sourceImage->imageData;
    	for(int i=0;i<sourceImage->height;i++)
    		for(int j=0;j<sourceImage->width;j++)
    			for(int h=0;h<channels;h++)
    			data[i*step+j*channels+h]=255-data[i*step+j*channels+h];
    	cvNamedWindow("Reverse",0);
    	cvShowImage("Reverse",sourceImage);
    	cvWaitKey(-1);
    	cvDestroyWindow("Reverse");
    	cvDestroyWindow("sourceImage");
    	return 0;
    }

    Reference:

    《学习opencv》

  • 相关阅读:
    zookeeper C API
    《accelerated c++》第九章---设计类
    redis memcache 比较
    redis 学习记录
    php memcache 使用学习
    php新手需要注意的高效率编程
    linux常用命令
    curl和file_get_contents 区别以及各自的优劣
    php序列化问题
    socket编程 123
  • 原文地址:https://www.cnblogs.com/snake-hand/p/3151257.html
Copyright © 2011-2022 走看看