The opencv image processing program has been rewritten to C++→Python.
Among them, there was an element-by-element subtraction of the array (120, 109, 3), but this result does not fit between the two programs.
The results so far are exactly the same and should only be calculations of (the same number) - (the same number).
I'd appreciate it if you could give me some tips on how to do it or what's wrong.
I look forward to your kind cooperation.
4/15 Add
Regarding the code, please consider src and src2 as images.
What exactly do you want to do?
○ C++
// src, src2 is cv::Mat type
for(inti=0;i<3,++i){
// Repeat this action three times
src = src-src2;
}
○ Python
#src,src2 is of type numpy.ndarray
for i in range (3):
// Repeat this action three times
src = src-src2
The header relationship is opencv2(C++) and cv2, numpy(Python).
Also, please let me know if you feel that there is a lack of information.
I solved myself.It seems that handling negative values was a problem.
For example, if you subtract 10 from 20 three times, C++ would say 0 and Python would say 245 at (255)-10.
Therefore, when we incorporated an operation to force a negative value in Python's result to replace it with zero, it matched the C++ result.
Thank you for everything.
For the same value, follow the process of calculating (subtracting by element) between the two programs to determine the calculation immediately before the program makes a difference.
The operation returns different values for the same value, so there should be a difference somewhere.
© 2024 OneMinuteCode. All rights reserved.