1. 程式人生 > >OpenCV改變像素顏色

OpenCV改變像素顏色

pos pla lang code shee col amp pen html


Mat src=imread("image/color.jpg");
	imshow("a",src);
	int i,j;
	int cPointR,cPointG,cPointB,cPoint;//currentPoint;
	for(i=1;i<src.rows;i++)
		for(j=1;j<src.cols;j++)
		{
			cPointB=src.at<Vec3b>(i,j)[0];
			cPointG=src.at<Vec3b>(i,j)[1];
			cPointR=src.at<Vec3b>(i,j)[2];
			if(cPointB>100&cPointR<100&cPointG<100)
				{
					src.at<Vec3b>(i,j)[0]=0;
					src.at<Vec3b>(i,j)[1]=0;
					src.at<Vec3b>(i,j)[2]=0;
			}
			
		}
	imshow("da",src);



OpenCV改變像素顏色