Ask Your Question

Revision history [back]

I don't understand why theshold result type is CV_32F:

Mat croppedDifferenceImage(256,256,CV_32FC1);
for (int i=0;i<croppedDifferenceImage.rows;i++)
for (int j=0;j<croppedDifferenceImage.cols;j++)
    croppedDifferenceImage.at<float>(i,j)=i/10.;
cv::Mat mask,maskBin ;
cv::threshold(croppedDifferenceImage, mask, 3.2, 255, CV_THRESH_BINARY);
mask.convertTo(maskBin,CV_8U);
imshow("r",mask);
double mean = cv::mean(croppedDifferenceImage, maskBin)[0];

cout<<mean;

I don't understand why theshold result Theshold result type is CV_32F:same type of source image so it is CV_32F. You don't need initialisation before threshold called

Mat croppedDifferenceImage(256,256,CV_32FC1);
for (int i=0;i<croppedDifferenceImage.rows;i++)
for (int j=0;j<croppedDifferenceImage.cols;j++)
    croppedDifferenceImage.at<float>(i,j)=i/10.;
cv::Mat mask,maskBin ;
cv::threshold(croppedDifferenceImage, mask, 3.2, 255, CV_THRESH_BINARY);
mask.convertTo(maskBin,CV_8U);
imshow("r",mask);
double mean = cv::mean(croppedDifferenceImage, maskBin)[0];

cout<<mean;