Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Find pixel color out of cv::Mat on specific position

well my problem is, I need to find the sub matrix of a cv::Mat image which includes all white pixels. Therefore I want to iterate through all pixels, check if they are white and build a cv::Rect with that information.
I figured out how to iterate through all the pixels but I don't know how to get the pixels color out of it. The cv::Mat was previously converted to greyscale with CV_GRAY2BGR

for(int y = 0; y < outputFrame.rows; y++)
{
    for(int x = 0; x < outputFrame.cols; x++)
    {
        // I don't know which datatype I should use
        if (outputFrame.at<INSERT_DATATYPE_HERE>(x,y) == 255)
           //define area
    }
}

My final question is, which datatype should I insert in the code on the position INSERT_DATATYPE_HERE and is 255 the right value to compare with than?

Thanks alot