I have two CV_32F images V1 and V2, of same size 512x512
I am trying to do:
float epsilon = 0.05f;
cv::Mat V = cv::abs(V1-V2);
cv::Mat mask = V < epsilon;
V1.setTo(V2, mask);
I checked that mask is a 512x512 CV_8U image.
setTo triggers a "checkScalar" assertion fail.
When I read the documentation of setTo, it says:
mask
Operation mask of the same size as *this. Its non-zero elements indicate which matrix elements need to be copied. The mask has to be of type CV_8U and can have 1 or multiple channels
Is the documentation wrong? Does mask have to be another type than CV_8U when masking a CV_32F image?
setTo()is only for spreading a scalar across the Mat subject.For array data, you want
copyTo(). Note that this pushes data into the argument Mat, doesn't pull it into the subject Mat. Themargument receives those values. Flip subject and argument, relative to your previoussetTo()attempt.The docs specify input arguments to be a generic
InputArrayvery often but the actual type is restricted at runtime (checkScalarand such). The docs forsetTo()say that it's expecting a scalarvalue(), which means no array types.I don't know why you'd question the
maskargument or the Mat element type. That's all fine.