Ask Your Question

Alvaro's profile - activity

2017-08-02 08:28:42 -0600 received badge  Student (source)
2017-08-02 04:04:23 -0600 asked a question Double number product matrix

I have tried to multipliate a number with a matrix, the problem is the next: if i do this operation:

Mat deriv_1 = Mat(groundTruth.size[1], groundTruth.size[0], CV_64F);
double number = 1 / 256;
deriv_1 = -number*(groundTruth - probs);// (-1 / M)*(groundTruth - probs);

all the numbers of matrix are 0 but if i do this:

Mat deriv_1 = Mat(groundTruth.size[1], groundTruth.size[0], CV_64F);
deriv_1 = -0.0039*(groundTruth - probs);// (-1 / M)*(groundTruth - probs);

the result is correct. i dont know why.

2017-07-31 06:16:17 -0600 commented answer Resize Mat error components

Yes!!! Thank you so much.

2017-07-31 05:58:28 -0600 asked a question Fill a vector<vector<Mat>>

I want to fill a vector<vector<mat>> B with a Mat dest, this matrix will change in a for loop. The problem is B[0][0] is the same that B[last_number][last_numer]. Here is the code:

vector<vector<Mat>> B;
for (int i = 0; i<2; i++) {
    B.push_back(vector<Mat>());
    for (int j = 0; j < 3; j++)
        B[i].push_back(Mat::zeros(10, 10, CV_64F));
}

Mat dest = Mat::ones(10, 10, CV_64F);
for (int i = 0; i<2; i++) {
    for (int j = 0; j < 3; j++)
    {
        dest = 2 * dest;
        B[i][j] = dest;
    }
}

cout << B[0][0];

An this is the output:

[64, 64, 64, 64, 64, 64, 64, 64, 64, 64;
 64, 64, 64, 64, 64, 64, 64, 64, 64, 64;
 64, 64, 64, 64, 64, 64, 64, 64, 64, 64;
 64, 64, 64, 64, 64, 64, 64, 64, 64, 64;
 64, 64, 64, 64, 64, 64, 64, 64, 64, 64;
 64, 64, 64, 64, 64, 64, 64, 64, 64, 64;
 64, 64, 64, 64, 64, 64, 64, 64, 64, 64;
 64, 64, 64, 64, 64, 64, 64, 64, 64, 64;
 64, 64, 64, 64, 64, 64, 64, 64, 64, 64;
 64, 64, 64, 64, 64, 64, 64, 64, 64, 64]
2017-07-28 05:02:18 -0600 asked a question Resize Mat error components

I want to resize a matrix but the components are diferents. This is the code

int p = 0;
Mat A = Mat(20,20, CV_64F);
for (int i = 0; i < 20; i++)
{
    for (int j = 0; j < 20; j++)
    {
        A.at<double>(i, j) = p;
        p++;
    }
}
cout << A <<endl;

Mat m = A.col(0);
for(int i=0;i<A.cols-1;i++)
vconcat(m, A.col(i+1), m);

Mat z = m(Range(0, 4), Range(0, 1));
Mat dest;
cout << z <<endl;
resize(z, dest, cv::Size(2, 2));
cout << dest <<endl;

and this the output:

[0;
 20;
 40;
 60]
[10, 10;
 50, 50]

The first output is a matrix z, and the sencond is matrix is produce by the resizing of the mat z.

2017-07-28 04:07:59 -0600 received badge  Supporter (source)
2017-07-28 03:46:37 -0600 received badge  Enthusiast
2017-07-26 04:49:53 -0600 commented answer Mat declaration: declaration dimensions and size() are differents

Thank you, i thought that was a problem :)

2017-07-26 04:46:28 -0600 commented question how can i reshape a Mat 2D to vector<vector<Mat>>

i found a solution:

vector<vector<Mat>> B;
for (int i = 0; i<dim1; i++) {
    B.push_back(vector<Mat>());
    for (int j = 0; j<dim2; j++)
        B[i].push_back(Mat(dim3, dim4, CV_64F, Scalar::all(1)));
}
Mat in = A.reshape(1, 1);
Mat subImg;
for (int i = 0; i < 256; i++)
{
    for (int j = 0; j < 20; j++)
    {
        subImg = in(cv::Range(0, 1), cv::Range(100 * j, 100 * j + 100));
        subImg.reshape(10, 10);
        B[i][j] = subImg;
    }
}
return B;
2017-07-26 04:42:05 -0600 asked a question Mat declaration: declaration dimensions and size() are differents

I declare a Mat as Mat mu = Mat::ones(2000, 256, CV_64F); and when i do cout << size(mu); the output is "[256, 2000]". This only happens in some parts of the code and I can understand that.

2017-07-25 05:31:28 -0600 received badge  Editor (source)
2017-07-25 04:10:51 -0600 asked a question how can i reshape a Mat 2D to vector<vector<Mat>>

i would like to convert a Mat whose dimensions are [2000][256] and i want to convert this to a vector<vector<mat>> with dimensions [256][20][10][10]. In matlab it is posible to do reshape(Mat2d, 10, 10, 20, 256), i would like to do the same

2017-07-25 03:33:09 -0600 received badge  Scholar (source)
2017-07-25 03:33:09 -0600 received badge  Scholar (source)
2017-07-25 03:33:08 -0600 received badge  Scholar (source)
2017-07-25 03:31:28 -0600 commented answer how can i "reshape" a matrix 4d to matrix 2d and vice versa?

Thank you so much!!!

2017-07-24 06:03:22 -0600 asked a question how can i "reshape" a matrix 4d to matrix 2d and vice versa?

i have a matrix vector<vector<mat>> with [256][20][10][10] dimensions and i want to convert this in a Mat matrix with [2000][256] dimensions. Thanks for all.

2017-07-20 03:41:57 -0600 asked a question How can i reshape a Mat to a vector<Mat>?

In Matlab that is possible with reshape function. Moreover i would like to reshaping a matrix to a vector<vector<mat>>