overflow encountered in ubyte_scalars

Problem Description

reason

The above warning means that the result exceeds the type representation range, and the final result will be processed within the set range. When the array type is np.uint8, if the sum of the array values ​​exceeds 255, the above warning will appear, and the result will be processed to 0-255 Between, taking the value in the figure as an example, the processing method is:
233+212=445>255
445-256=189<255
189+108=297>255
297-256=41<255
, so the final addition result is 41.

as a result of

If you use the above method and ignore the warning completely, misjudgment may occur when comparing the addition of multiple pixel values ​​​​in the picture.

Solution

It is recommended to use the sum method to sum all pixel values ​​and then compare the results.

Guess you like

Origin blog.csdn.net/qq_36949278/article/details/131207105