3

I want to do an operation like this however I cannot get the values of the vector Mat and change them. table is a 1 dimensional array by the way. Thanks.

vector<Mat> orjchannel; 
vector<Mat> refchannel; 

// There are some functions here 

for (int i = 0; i < 512; i++){
    for (int j = 0; j < 512; j++){
        double value = refchannel[i][j]; // This part does not work 
        orjchannel[i][j] = tables[value];
5
  • operator[] takes 1 integer. Did you mean [i][j]?
    – Neil Kirk
    Commented Oct 16, 2014 at 0:53
  • Yes since I dont konw how to reach that value I wrote somthing like what I mean
    – s900n
    Commented Oct 16, 2014 at 0:55
  • I edited it that way it does not work as well
    – s900n
    Commented Oct 16, 2014 at 0:57
  • Does Mat have operator[]?
    – Neil Kirk
    Commented Oct 16, 2014 at 1:00
  • What type is tables? You're trying to access a 1D vector refchannel with double indices.
    – a-Jays
    Commented Oct 16, 2014 at 3:24

1 Answer 1

8

With OpenCV, you typically access the values of a Mat with the at<DATATYPE>(r,c) command. For example...

// Mat constructor
Mat data(4, 1, CV_64FC1);

// Set Value
data.at<double>(0,0) = 4;

// Get Value
double value = data.at<double>(0,0);    
1
  • 1
    To further increase on this answer; You would need to use; refchannel.at(i).at<double>(j,k). The first 'at' selects one of the Mat objects in the vector, the second gives you the specified value in the mat (of the specified type).
    – Nallath
    Commented Oct 16, 2014 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.