0

I push back two sets(A={A1,A2,A3},B={B1,B2,B3}) of equal matrices(A1=B1,A2=B2,A3=B3) of same type(CV_32FC) in two different vectors(Va and Vb) of same type. When i compare the contents of the vectors pair by pair(Va[0] vs Vb[0], Va[1] vs Vb[1],Va[2] vs Vb[2])they are different. How is this possible?

Code explanation:

A= imgs_lab_channels. 
Lab_channel_current_FG = Foreground image 
Lab_channel_current_BG = Background image
Lab_channel_current=Lab_channel_current_FG+Lab_channel_current_BG
push Lab channel_current into vector Lab_channels
So B=Lab_channels

I check that

Lab_channel_current= imgs_lab_channels[i].

When I read back the matrices from the vectors A and B they are different.

Code snippet:

std::vector<cv::Mat> imgs_lab_channels;
split(imgs_lab, imgs_lab_channels); 
std::vector<cv::Mat> Lab_channels;
cv::Mat Lab_channel_current_FG;
cv::Mat Lab_channel_current_BG;
cv::Mat Lab_channel_current;
for(int i = 0; i < 3; i++)
{
// FG_mask and BG_mask are 0-1 binary matrices of type 32FC1 
// and with same size as imgs_lab_channels. FG_mask and BG_mask
// select the Foreground and background respectively. Omitted for  
// sake of clarity

    Lab_channel_current_FG=imgs_lab_channels[i].mul(FG_mask);
    Lab_channel_current_BG=imgs_lab_channels[i].mul(BG_mask);
    // add the FG and the BG image
    Lab_channel_current=Lab_channel_current_FG+Lab_channel_current_BG;
    Lab_channels.push_back(Lab_channel_current);
}
for(int j=0;j<3;j++)
{
    temp2 = Lab_channels[j]-imgs_lab_channels[j];
    double min2, max2;
    cv::minMaxLoc(temp2, &min2, &max2);
    std::cout << "temp2 min,max="<< min2 << "," << max2 << std::endl;
}
user27665
  • 673
  • 7
  • 27

0 Answers0