读取图像的像素值
来源:互联网 发布:南笙 知乎 编辑:程序博客网 时间:2024/05/21 13:34
#include "StdAfx.h"
#include"iostream"
#include <fstream>
using namespace std;
#include "cv.h"
#include "highgui.h"
#include <opencv2/opencv.hpp>
int main(int argc, char* argv[])
{
/* ①
IplImage*img = cvLoadImage("rgb.bmp",-1);
if(img==NULL)
return 0;
CvScalar p;
ofstream outfile("d:\\rgb.txt");
outfile<<"图像宽和高:"<<img->width<<"*"<<img->height<<endl;
for(int i=0;i<img->height;i++)
{
for(int j=0;j<img->width;j++)
{
p = cvGet2D(img,i,j);
outfile<<p.val[0] <<" "<<p.val[1]<<" "<<p.val[2] <<" "<<endl;
}
}
*/
///* ②
IplImage* img = cvLoadImage("d://测试/Lena.jpg",-1);
CvScalar p;
ofstream outfile1("d:\\b.txt");
ofstream outfile2("d:\\g.txt");
ofstream outfile3("d:\\r.txt");
outfile1<<"图像宽和高:"<<img->width<<"*"<<img->height<<endl;
outfile1<<"图像B值"<<endl;
outfile2<<"图像宽和高:"<<img->width<<"*"<<img->height<<endl;
outfile2<<"图像G值"<<endl;
outfile3<<"图像宽和高:"<<img->width<<"*"<<img->height<<endl;
outfile3<<"图像R值"<<endl;
//cvFlip(img);
for(int i=0;i<img->width;i++)
{
for(int j=0;j<img->height;j++)
{
p = cvGet2D(img,i,j);//(j,i)
outfile1<<p.val[0]<<" ";
outfile2<<p.val[1]<<" ";
outfile3<<p.val[2]<<" ";
}
outfile1<<endl;
outfile2<<endl;
outfile3<<endl;
} //*/
return 0;
}
#include"iostream"
#include <fstream>
using namespace std;
#include "cv.h"
#include "highgui.h"
#include <opencv2/opencv.hpp>
int main(int argc, char* argv[])
{
/* ①
IplImage*img = cvLoadImage("rgb.bmp",-1);
if(img==NULL)
return 0;
CvScalar p;
ofstream outfile("d:\\rgb.txt");
outfile<<"图像宽和高:"<<img->width<<"*"<<img->height<<endl;
for(int i=0;i<img->height;i++)
{
for(int j=0;j<img->width;j++)
{
p = cvGet2D(img,i,j);
outfile<<p.val[0] <<" "<<p.val[1]<<" "<<p.val[2] <<" "<<endl;
}
}
*/
///* ②
IplImage* img = cvLoadImage("d://测试/Lena.jpg",-1);
CvScalar p;
ofstream outfile1("d:\\b.txt");
ofstream outfile2("d:\\g.txt");
ofstream outfile3("d:\\r.txt");
outfile1<<"图像宽和高:"<<img->width<<"*"<<img->height<<endl;
outfile1<<"图像B值"<<endl;
outfile2<<"图像宽和高:"<<img->width<<"*"<<img->height<<endl;
outfile2<<"图像G值"<<endl;
outfile3<<"图像宽和高:"<<img->width<<"*"<<img->height<<endl;
outfile3<<"图像R值"<<endl;
//cvFlip(img);
for(int i=0;i<img->width;i++)
{
for(int j=0;j<img->height;j++)
{
p = cvGet2D(img,i,j);//(j,i)
outfile1<<p.val[0]<<" ";
outfile2<<p.val[1]<<" ";
outfile3<<p.val[2]<<" ";
}
outfile1<<endl;
outfile2<<endl;
outfile3<<endl;
} //*/
return 0;
}
0 0
- 读取图像的像素值
- opencv读取图像像素值
- opencv图像像素值读取
- opencv读取图像像素值
- 读取图像中任意点的像素值
- opencv对于bmp图像像素值的读取和赋值
- 读取图像中任意点的像素值
- ArcGIS二次开发之读取遥感图像像素值的做法
- OpenCV中用于读取图像像素点的值
- 整理关于python读取图像的像素
- 用opencv读取图像的每个像素值,鼠标点击获取每一个点,并显示像素
- OpenCV中读取图像像素值
- opencv读取图像,并获得像素值,图像高度和宽度不是4的倍数
- OpenCV中读取图像像素值 - [图像处理\OpenCV编程]
- 图像像素值的反转
- 图像中获取图像的像素值
- MFC CImage 读取图像 像素
- ITK 读取三维的mha 如何遍历像素值 以及对mha 图像的小认识
- Linux MySQL的使用
- destructor(析构函数)
- Jbpm4.4 使用
- Python 正则表达式限定文本长度
- 使用jQuery的formValidator框架对表单数据实现前台校验
- 读取图像的像素值
- windows下安装elasticsearch
- 新产品开发的周期越来越短,而模具又是在新产品开发中费时最多的项目之一
- 最长公共子列长度O(2*min(l1,l2))大小空间解法
- 2014/7/24
- 互联网产品运营管理知识一网打尽
- svn切换已登录用户
- jni混编(c++调用java方法)
- 通过金矿模型介绍动态规划(讲得真心不错~~~)