Ask Your Question

Revision history [back]

Hi @rafoc

If you have a Mat like this & if you want to find the divided result of Blue & Red Intensity You can do like this.

Mat InputImage= Mat::zeros(640,480,CV_32FC3);
Mat DividedResult= Mat::zeros(640,480,CV_32FC1);
for (int Row = 0; Row < InputImage.rows; Row++)
{
    for (int Col = 0; Col < InputImage.cols; Col++)
    {
        Vec3f PixelValue= InputImage.at<Vec3f>(Row,Col);
        DividedResult.at<float>(Row,Col)= PixelValue.val[0]/PixelValue.val[2];// Blue Intensity / Red Intensity
    }
}