#include<Windows.h>
#include<cv.h>
#include<highgui.h>
#include <cxcore.h>
int main(){
IplImage* img = cvLoadImage("1.jpg");
IplImage* dst = cvCreateImage(cvGetSize(img),img->depth,1);
cvNamedWindow("GRAY");
cvCvtColor(img,dst,CV_BGR2GRAY);
int height = dst->height;
int width = dst->width;
int step = dst->widthStep;
int channels = dst->nChannels;
uchar *data = (uchar *)dst->imageData;
for(int i=0;i<height;i++){
for(int j=0;j<width;j++){
for(int k=0;k<channels;k++){
if(data[i*step+j*channels+k]<210)data[i*step+j*channels+k]=255;
else data[i*step+j*channels+k]=0;
}
}
}
while(1){
cvShowImage("GRAY",dst);
if(cvWaitKey())break;
}
cvReleaseImage(&img);
return 0;
}
实验2014062701:opencv对图像的点操作,布布扣,bubuko.com