OpenCV静心修炼总结篇6——图像亮度与对比度调节

图像的亮度与对比度调节原理

   

参考代码:

int image_change_bright()
{
   Mat src,dst;
   src = imread("E:\\1.png");
   if(src.empty())
   {
      printf("打开图像失败\n");
	  return -1;
   }
   imshow("input image",src);

   int height =src.rows;
   int wide =src.cols;
   dst = Mat::zeros(src.size(),src.type());
   int alpha = 1.5;
   int bate =50;
   for(int row=0;row(row,col)[0];
			   int g= src.at(row,col)[1];
			   int r= src.at(row,col)[2];

			   dst.at(row,col)[0]=saturate_cast(b*alpha+bate);
			   dst.at(row,col)[1]=saturate_cast(g*alpha+bate);
			   dst.at(row,col)[2]=saturate_cast(r*alpha+bate);
		   }
		  
	   }
	   imshow("output",dst);
	   waitKey(0);
}

 

你可能感兴趣的:(OpenCV)