Ask Your Question

trucna's profile - activity

2016-10-22 00:50:38 -0600 received badge  Enthusiast
2016-10-15 15:03:15 -0600 commented question Filestorage: how to save Mat with more columns

I need it for Matlab and Mathematica basically. Thank you for cv::Formatter, looks promising!

2016-10-15 06:18:00 -0600 commented question Filestorage: how to save Mat with more columns

They are not meaningless for me, I need data in perfect match with columns and rows for 3rd party processing.

This is why I am asking, if there is a simple way how to do it and suppress this "internal OpenCV thing".

2016-10-15 05:06:11 -0600 asked a question Filestorage: how to save Mat with more columns

Filestorage used like like this

Mat G;
...
FileStorage file_func_g_comp("func_g_comp.xml", FileStorage::WRITE);

file_func_g_comp << "MyData" << G;
file_func_g_comp.release();

stores data in xml like this

<?xml version="1.0"?>
<opencv_storage>
<MyData type_id="opencv-matrix">
  <rows>501</rows>
  <cols>501</cols>
  <dt>f</dt>
  <data>
    -2.34666206e-002 -2.34663915e-002 -2.34661158e-002 -2.34658401e-002
    -2.34655663e-002 -2.34652907e-002 -2.34650150e-002 -2.34647393e-002
    -2.34644637e-002 -2.34641880e-002 -2.34639123e-002 -2.34636385e-002
    -2.34633628e-002 -2.34630872e-002 -2.34628115e-002 -2.34625377e-002
    -2.34622620e-002 -2.34619863e-002 -2.34617107e-002 -2.34614350e-002
    -2.34611612e-002 -2.34608855e-002 -2.34606098e-002 -2.34603342e-002
    -2.34600604e-002 -2.34597847e-002 -2.34595090e-002 -2.34592333e-002
    -2.34589577e-002 -2.34586820e-002 -2.34584082e-002 -2.34581325e-002
    -2.34578568e-002 -2.34575830e-002 -2.34573074e-002 -2.34570317e-002
    -2.34567560e-002 -2.34564804e-002 -2.34562065e-002 -2.34559309e-002
    -2.34556552e-002 -2.34553814e-002 -2.34551057e-002 -2.34548301e-002
    -2.34545544e-002 -2.34542787e-002 -2.34540049e-002 -2.34537292e-002
    -2.34534536e-002 -2.34531797e-002 -2.34529041e-002 -2.34526284e-002
    -2.34523527e-002 -2.34520789e-002 -2.34518033e-002 -2.34515276e-002
    -2.34512538e-002 -2.34509781e-002 -2.34507024e-002 -2.34504268e-002
    -2.34501511e-002 -2.34498773e-002 -2.34496016e-002 -2.34493259e-002
    -2.34490521e-002 -2.34487765e-002 -2.34485008e-002 -2.34482251e-002
    -2.34479513e-002 -2.34476756e-002 -2.34474018e-002 -2.34471262e-002
    -2.34468505e-002 -2.34465748e-002 -2.34462991e-002 -2.34460253e-002
    -2.34457497e-002 -2.34454740e-002 -2.34452002e-002 -2.34449245e-002...

My problem is that I need data to be stored as a matrix 501 x 501, not like that (in four columns), for future processing in another software.

Is there a way how to do it?

2015-06-02 03:59:42 -0600 commented answer cv::Mat element matrix multiplication

Thank you, but this is not a solution. You still need to somehow choose concrete element from Mat a. The choosing part is the one not working. This:

a.row(0).col(0)

can not be applied in multiply and here is the problem.

Btw, I am focused on performance in this implementation, so I would like to not doing such a stuff from your advice, unless absolutely necessary.

2015-06-01 11:05:37 -0600 commented question cv::Mat element matrix multiplication

I have added an example.

2015-06-01 11:04:32 -0600 received badge  Editor (source)
2015-06-01 10:37:56 -0600 asked a question cv::Mat element matrix multiplication

I need to take concrete element from three channel matrix:

a.row(0).col(0)

and use this element for multiplication:

multiply(a.row(0).col(0), b, c);

Something like this:

Mat a(5, 5, CV_32FC3);  
Mat b(5, 5, CV_32FC3); 
Mat c;

multiply(a.row(0).col(0), b, c);

But it is not working. Do you have some tip how to do it?

P.S. : it is really easy for one channel image using

a.at<float>(0,0)

Edit

Ok, let me give an example.

Mat a:

[ 91,   2,  79, 179,  52, 205, 236,   8, 181, 239,  26, 248, 207, 218,  45;
 183, 158, 101, 102,  18, 118,  68, 210, 139, 198, 207, 211, 181, 162, 197;
 191, 196,  40,   7, 243, 230,  45,   6,  48, 173, 242, 125, 175,  90,  63;
  90,  22, 112, 221, 167, 224, 113, 208, 123, 214,  35, 229,   6, 143, 138;
  98,  81, 118, 187, 167, 140, 218, 178,  23,  43, 133, 154, 150,  76, 101]

Mat b:

[  8,  38, 238,  84,  47,   7, 117, 246, 163, 237,  69, 129,  60, 101,  41;
 190,  50,  90,  72, 168, 109, 121, 220, 114, 248,  99, 202, 199, 212,  79;
 128, 198,  90, 168,  76, 145, 181, 118,   8,  63, 114, 217, 164, 158, 217;
 237, 147,  44, 207,  54, 182,  65, 197, 191, 239,  72, 166, 236, 240,   3;
 151,  91, 246, 116, 238,  94,  63, 252, 232,  25,  17,   8, 166, 116,  81]

I want to take element [0; 0] from the a which is (91, 2, 79) and use it for per-element multiplication to achieve Mat c:

[  728, 76, 18802, 7644, 94, 553, 10647, 492, 12877, 21567, 138, 10191, 5460, 202, 3239;
 17290, 100, 7110, 6552, 336, 8611, 11011, 440, 9006, 22568, 198, 15958, 18109, 424, 6241;
 11648, 396, 7110, 15288, 152, 11455, 16471, 236, 632, 5733, 228, 17143, 14924, 316, 17143;
 21567, 294, 3476, 18837, 108, 14378, 5915, 394, 15089, 21749, 144, 13114, 21476, 480, 237;
 13741, 182, 19434, 10556, 476, 7426, 5733, 504, 18328, 2275, 34, 632, 15106, 232, 6399]