Zugang zu Mat binären Bilder durchgeführt, Elemente in OpenCV

Habe ich versucht, den folgenden code zu drucken, alle weißen Pixel dieses binäre Bild, ohne Erfolg:

Mat grayImage;
Mat rgb_Image;
int Max_value = 255;
int Global_Threshold = 155;

rgb_Image = imread( "../Tests/Object/Object.jpg", CV_LOAD_IMAGE_COLOR);   //Read the file

if(! rgb_Image.data )  //Check for invalid input
{
        cout <<  "Could not open or find the image" << endl ;
        return -1;
}

//Convert to Grayscale.
cvtColor(rgb_Image, grayImage, CV_BGR2GRAY);

//Binarize the image with a fixed threshold.
threshold( grayImage, binImage, Global_Threshold, Max_Value, 0);

//Printing white pixels
for(int i = 0; i < 640; i++)
{
    for(int j = 0; j < 480; j++)
    {
        if(255 == binImage.at<float>(i,j))
        {
            cout << binImage.at<float>(i,j) << endl;
        }
    }
}

Wenn ich drucken Sie die Werte nicht Nullen, bekomme ich komische Werte, aber nicht 255.

Dank,

InformationsquelleAutor andrestoga | 2012-07-11
Schreibe einen Kommentar