(代码2)读入一幅图像将之反色并显示
来源:互联网 发布:java最新框架组合 编辑:程序博客网 时间:2024/05/17 02:06
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <cv.h>
#include <highgui.h>
int main(int argc, char *argv[])
{
IplImage* img = 0;
int height,width,step,channels;
uchar *data;
int i,j,k;
// load an image
const char* imagename = "lena.jpg";
img=cvLoadImage(imagename);
if(!img){
printf("Could not load image file: %s\n",argv[1]);
exit(0);
}
// get the image data
height = img->height;
width = img->width;
step = img->widthStep;
channels = img->nChannels;
data = (uchar *)img->imageData;
printf("Processing a %dx%d image with %d channels\n",height,width,channels);
// create a window
cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE);
cvMoveWindow("mainWin", 100, 100);
// invert the image
// 相当于 cvNot(img);用这个函数前面的许多代码(// get the image data)都可以不要了。。。
// IplImage *pDstImg = cvCreateImage(cvGetSize(img),img->depth,img->nChannels);
// show the image
cvShowImage("mainWin", img ); //如果之前用的cvNot,则这里是 pDstImg
// wait for a key
cvWaitKey(0);
// release the image
cvReleaseImage(&img );
return 0;
}
#include <stdio.h>
#include <math.h>
#include <cv.h>
#include <highgui.h>
int main(int argc, char *argv[])
{
IplImage* img = 0;
int height,width,step,channels;
uchar *data;
int i,j,k;
// load an image
const char* imagename = "lena.jpg";
img=cvLoadImage(imagename);
if(!img){
printf("Could not load image file: %s\n",argv[1]);
exit(0);
}
// get the image data
height = img->height;
width = img->width;
step = img->widthStep;
channels = img->nChannels;
data = (uchar *)img->imageData;
printf("Processing a %dx%d image with %d channels\n",height,width,channels);
// create a window
cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE);
cvMoveWindow("mainWin", 100, 100);
// invert the image
// 相当于 cvNot(img);用这个函数前面的许多代码(// get the image data)都可以不要了。。。
// IplImage *pDstImg = cvCreateImage(cvGetSize(img),img->depth,img->nChannels);
// cvNot(img, pDstImg);
for(i=0;i<height;i++)
for(j=0;j<width;j++)
for(k=0;k<channels;k++)
data[i*step+j*channels+k]=255-data[i*step+j*channels+k];// show the image
cvShowImage("mainWin", img ); //如果之前用的cvNot,则这里是 pDstImg
// wait for a key
cvWaitKey(0);
// release the image
cvReleaseImage(&img );
return 0;
}
- (代码2)读入一幅图像将之反色并显示
- 初学openCV 之从文件中读入一幅图像,将之反色并显示
- 该程序从文件中读入一幅图像,将之反色,然后显示出来
- (代码1)读入并显示图像
- 读入并显示一幅图像—system generator
- VC++6.0下通过opencv读入图像并反色
- 利用OpenCV读入,显示并保存图像
- Windows程序设计(2):载入一幅图像并显示
- Firworks 8之旅(一)使用橡皮擦工具将图像擦除并填色
- OpenCV(一)显示一幅图像代码详细讲解
- 使用halcon(版本10.0 64位)读入图像并进行显示,使用ChartAxis类实现图像直方图的显示?
- 读入图像文件并显示【C#图像处理学习笔记】
- openCV 利用Mat 类读入并显示图像
- EmguCV第一个程序,读入图像并显示
- opencv图像的读入、灰度化、二值化、反色
- opencv图像的读入、灰度化、二值化、反色
- opencv图像的读入、灰度化、二值化、反色
- 将TXT文件读入到容器并显示
- 在Fedora 10上编译vlc1.0.2全程笔记
- JS 实现右键菜单
- 从此刻立志——我要做大牛
- Reverse Conditional -- 反转条件
- size_t
- (代码2)读入一幅图像将之反色并显示
- 关于Hibernate下Configuration类的buildSessionFactory()方法过期
- Android菜单详解(四)——使用上下文菜单ContextMenu
- 区域化 NSLocale Class
- Android中的popWindow
- 【整理】LINUX下使用CMAKE安装MYSQL
- 删除所有的.svn文件夹
- nagios使用check_mysql监控mysql
- 我作为前端工程师为什么会向后端工程师推荐Node.js