-3

I am doing a project on image encryption and decryption. So I need to extract RGB Color components in a color image. Please clear my doubt in open cv using c++. Thanks in advance. Deepak Chiradoni

1 Answers1

0

first load your image as

 Mat img=imread(file_name);

It returns img in BGR format. Now use following code snippet to access color components in BGR image. here y-row index and x-column index

Vec3b intensity = img.at<Vec3b>(y, x);
uchar blue = intensity.val[0];
uchar green = intensity.val[1];
uchar red = intensity.val[2];

Reference: http://docs.opencv.org/doc/user_guide/ug_mat.html

ssh99
  • 309
  • 1
  • 3
  • 16