Ask Your Question

Cima's profile - activity

2014-05-27 12:18:45 -0600 commented question Mat::data empty after image operation (threshold())

No I am sure there are values above 220 ( I am able to display the thresholded image with imshow()). Simply the data-array of the new mat is 0 (it has no values, but mat.empty() is NOT true).

I think it could be something with referencing and copying mat::data

2014-05-27 11:13:11 -0600 asked a question Mat::data empty after image operation (threshold())

Dear all,

In my code I want to

  1. read in an image from file
  2. use threshold-operation on that image
  3. access the data from thresholded image, in order to read the pixel values

    `// read image source
    Mat src = imread("image.png", CV_LOAD_IMAGE_COLOR); if(src.empty()) {
    return -1; }

    cvtColor(src,src,CV_RGB2GRAY);

    threshold(src, src, 220, 255, CV_THRESH_BINARY );

    int line[1200];
    

    int lineCount = 0;

    for(int i=src.rows; i>src.rows/2; i-=10)
    { uchar* rowi = src.ptr(i-1);

    int columnCount = 0;
    // begin on the left of the image
    for(int j=0; j<src.cols; j++)
    {
        uchar grayscale = src.at<uchar>(rowi[j]);   
    
    
    // write data to array
    line[columnCount] = grayscale;
    
    columnCount++;
    
    }`

My Problem: After using the threshold-operation on the image the src::date is " ". What can I do to fix that?

Thanks, Cima