mat::ones last element is set as 4.9407e-324 (Bug #3857)


Added by Mustafa Teke over 10 years ago. Updated over 10 years ago.


Status:Cancelled Start date:2014-08-13
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:-
Target version:-
Affected version:2.4.0 - 2.4.8 Operating System:Windows
Difficulty: HW Platform:x64
Pull request:

Description

When I create an image from mat::ones(8193,1)
and save data to file using ofstream; I get two different results
1. printing with a for loop with each element, last item is printed to file as 4.9407e-324
2. printing the image as a whole everything seems fine

for (int imNum = 0; imNum < fileNames.size(); imNum++)
{
ofstream responseFile;
responseFile.open ( fileNames[imNum] );
responseFile<&lt;EstimatedResponses[imNum];
//responseFile <&lt;std::setprecision(5);
//for(int col = 0; col < EstimatedResponses[imNum].rows; col++)
//{
// responseFile<&lt;EstimatedResponses[imNum].at&lt;double&gt;(col, 1)<&lt;endl;
//}
responseFile.close();
}

History

Updated by be rak over 10 years ago

that's not a bug, but a plain programming error on your side.

your Mat has 8193 rows, 1 column, so , to iterate over that you would have to:

@@

for (int row=0; row&lt;img.rows; row++)  // iterate and compare over rows, not cols.
{
double d = img.at&lt;double&gt;(row,0); // 0, not 1 is the first and only valid index
}

@@

Updated by be rak over 10 years ago

that's not a bug, but a plain programming error on your side.

your Mat has 8193 rows, 1 column, so , to iterate over that you would have to:

    for (int row=0; row<img.rows; row++)  // iterate and compare over rows, not cols.
    {
        double d = img.at<double>(row,0); // 0, not 1 is the first and only valid index
    }

Updated by Dmitry Retinskiy over 10 years ago

  • Status changed from New to Cancelled

Also available in: Atom PDF