改变图像的部分通道值(图像指针操作)
2010-07-13 16:45
260 查看
// 3_11.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <cv.h>
#include <cvcam.h>
#include <cxcore.h>
#include <highgui.h>
#pragma comment(lib,"cv.lib")
#pragma comment(lib,"cvcam.lib")
#pragma comment(lib,"cxcore.lib")
#pragma comment(lib,"highgui.lib")
void Saturate_SV(IplImage *pSourceImage)
{
assert(pSourceImage != NULL);
for (int nHeight= 0; nHeight < pSourceImage->height; nHeight++ )
{
uchar *ptr = (uchar*)(pSourceImage->imageData + nHeight *pSourceImage->widthStep);
for (int nRow = 0; nRow < pSourceImage->width; nRow++)
{
ptr[nRow*3 +0] = 155;
ptr[nRow*3 +1] = 155;
}
}
}
int main(int argc, char* argv[])
{
IplImage *pSourceImage = cvLoadImage(argv[1]);
assert(pSourceImage != NULL);
IplImage *pDestImage = cvCloneImage(pSourceImage);
assert(pDestImage);
Saturate_SV(pDestImage);
cvNamedWindow("Show_Src");
cvNamedWindow("Show_Dst");
cvShowImage("Show_Src",pSourceImage);
cvShowImage("Show_Dst",pDestImage);
cvWaitKey();
cvReleaseImage(&pSourceImage);
cvReleaseImage(&pDestImage);
cvDestroyAllWindows();
return 0;
}
//
#include "stdafx.h"
#include <cv.h>
#include <cvcam.h>
#include <cxcore.h>
#include <highgui.h>
#pragma comment(lib,"cv.lib")
#pragma comment(lib,"cvcam.lib")
#pragma comment(lib,"cxcore.lib")
#pragma comment(lib,"highgui.lib")
void Saturate_SV(IplImage *pSourceImage)
{
assert(pSourceImage != NULL);
for (int nHeight= 0; nHeight < pSourceImage->height; nHeight++ )
{
uchar *ptr = (uchar*)(pSourceImage->imageData + nHeight *pSourceImage->widthStep);
for (int nRow = 0; nRow < pSourceImage->width; nRow++)
{
ptr[nRow*3 +0] = 155;
ptr[nRow*3 +1] = 155;
}
}
}
int main(int argc, char* argv[])
{
IplImage *pSourceImage = cvLoadImage(argv[1]);
assert(pSourceImage != NULL);
IplImage *pDestImage = cvCloneImage(pSourceImage);
assert(pDestImage);
Saturate_SV(pDestImage);
cvNamedWindow("Show_Src");
cvNamedWindow("Show_Dst");
cvShowImage("Show_Src",pSourceImage);
cvShowImage("Show_Dst",pDestImage);
cvWaitKey();
cvReleaseImage(&pSourceImage);
cvReleaseImage(&pDestImage);
cvDestroyAllWindows();
return 0;
}
相关文章推荐
- Opencv笔记——图像的部分基本操作(待补充)
- c#指针进行图像操作
- C# 指针操作图像 细化处理
- 指针和图像的操作
- c#指针进行图像操作
- 【通过操作指针,与指针做函数參数'实现字串在主串中出现的次数,然后将出现的部分依照要求进行替换 】
- OpenCV改变图像大小的操作
- OpenCV改变图像大小的操作,resize与图像金字塔方法
- 安卓实训第十二天(补充部分)---Sqlite数据库的创建和改变,以及使用SQLiteDataBase完成CRUD操作
- OpenCV改变图像大小的操作,resize与图像金字塔方法
- OpenCV学习笔记_用指针操作图像元素
- VTK修炼之道24:图像基本操作_单颜色通道图像合成彩色
- c++ builder\delphi中如何改变操作数据库时的鼠标指针形状
- c#指针进行图像操作
- BGRABitmap图像操作6:改变笔型,创建点线
- 外部托拽文件时,在目标区域改变光标图像,实现部分区域可以拖放。
- OpenCV改变图像大小的操作
- 通过操作指针,与指针做函数参数'实现字串在主串中出现的次数,然后将出现的部分按照要求进行替换
- OPENCV用户手册之图像处理部分(之三):形态学操作(中文翻译)
- 图像的通道和深度以及图像的像素点操作完全解析