Ask Your Question

Irenicus's profile - activity

2020-06-30 10:55:42 -0600 received badge  Popular Question (source)
2018-04-06 08:49:04 -0600 received badge  Student (source)
2015-04-30 05:14:13 -0600 commented question Convert binary image values to '0' '1' integers

I don't think so, I used imshow before use, maybe the problem stem from a different source, the Eclipse IDE behaves strangely for the last few days.

Thanks anyway.

2015-04-30 04:58:37 -0600 commented question Convert binary image values to '0' '1' integers

changing maxval produced a completely black image.

In any case, my goal is to understand which pixels are considered 'white', and which are 'black', in order to build class labels for classification, like I said. From what I see, there aren't just 2 values representing two colours, but much more.

I'm new to opencv, so I'm still unclear about how binary images are represented in it.

2015-04-30 04:25:11 -0600 received badge  Editor (source)
2015-04-30 04:22:50 -0600 asked a question Convert binary image values to '0' '1' integers

I'm trying to convert a binary mask (for an image) to an integer array, and so far I'm having trouble understanding how to regard the type and value of the pixels in this image.

I used a binary image file containing imgMask:

threshold(bgIsolation, imgMask, 10, 255, THRESH_BINARY);

image description

Then tried to convert it to an integer vector for later classification, using the following function:

void color_imgreshape_2_1(Mat &img, int *class_labels){
    int i = 0;
    cout << "rows: " << img.rows << " cols: " << img.cols << endl;
    for (int x = 0; x < img.cols; ++x){
        for (int y = 0; y < img.rows; ++y){
            class_labels[i++] = (int)img.at<uchar>(y,x);
        }
    }
    ofstream out("out.txt");
    cout.rdbuf(out.rdbuf()); //redirect std::cout to out.txt!
    for (int i = 0; i < img.rows * img.cols; i++)
        cout << class_labels[i] << endl;
    return;
}

Redirecting the labels vector output to a file, it appears that it contains different values, and no 1's or 0's.

So can anyone tell me how to convert those pixel values to integers?

2015-04-25 13:25:08 -0600 commented question Grayscale image conversion error in eclipse

Thanks!

It appears I had a typo in one of the libraries I linked.

2015-04-25 13:11:55 -0600 asked a question Grayscale image conversion error in eclipse

I created an eclipse project according to the instructions found in here, and everything worked fine for that example.

I then wanted to try another simple example of converting an image to grayscale, and received the following error message:

"undefined reference to symbol '_ZN2cv8cvtColorERKNS_11_InputArrayERKNS_12_OutputArrayEii'"

Anyone knows what the problem might be?