-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Closed
Labels
RFCcategory: documentationDocumentation fix or updateDocumentation fix or updatefutureThis issue can't be fixed during restrictions of the compatibility requirementsThis issue can't be fixed during restrictions of the compatibility requirements
Milestone
Description
System information (version)
- OpenCV => 3.2
- Operating System / Platform => Ubuntu 16.04
- Compiler => GCC 5.4.0
Detailed description
The documentation of divide says that
dst(I) = saturate(src1(I) * scale / src2(I))
Whensrc2(I)is zero,dst(I)will also be zero.
In other words, it should be safe to divide by zero. However, the behavior I observe with CV_64F matrices is not consistent and depends on the size of the matrices.
For small matrices (up to 3 elements) division outputs zeros, as expected. However, if the size of the matrices is 4 or more, division outputs infs.
Other data types behave as expected.
Steps to reproduce
#include <iostream>
#include <opencv2/core.hpp>
int main(int argc, const char** argv)
{
cv::Mat A = cv::Mat::ones(1, 4, CV_64FC1);
cv::Mat B = cv::Mat::zeros(1, 4, CV_64FC1);
std::cout << "A = " << A << std::endl;
std::cout << "B = " << B << std::endl;
std::cout << "A / B = " << cv::Mat(A / B) << std::endl;
return 0;
}Output is:
A = [1, 1, 1, 1]
B = [0, 0, 0, 0]
A / B = [inf, inf, inf, inf]
Additional info
$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 61
model name : Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz
stepping : 4
microcode : 0x24
cpu MHz : 2401.312
cache size : 4096 KB
physical id : 0
siblings : 4
core id : 0
cpu cores : 2
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 20
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dtsacpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avxf16c rdrand lahf_lm abm 3dnowprefetch epb intel_pt tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap xsaveopt dtherm ida arat pln pts
bugs :
bogomips : 4788.77
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
RFCcategory: documentationDocumentation fix or updateDocumentation fix or updatefutureThis issue can't be fixed during restrictions of the compatibility requirementsThis issue can't be fixed during restrictions of the compatibility requirements