};
Why is the operation S0 >> 4 performed when the resize function takes u8 input and a scalar for the V-direction? Since int32 would not overflow in the scalar case, why is this operation still necessary?
source code: opencv/modules/imgproc/src/resize.cpp at 5.x · opencv/opencv · GitHub
I might be misunderstanding something, but I would have thought that using floating-point arithmetic would yield higher precision than fixed-point arithmetic for processing u8 inputs. However, looking at the OpenCV source code, I see that fixed-point arithmetic is used instead. I would like to know the reason for this—thanks
fixed point arithmetic is integer arithmetic. this is usually cheaper than floating point arithmetic. it also leaves the floating point units free to do other things that really need floating point arithmetic.
as to what invokes this kernel, I can’t follow the execution backwards, nor can I trace where the operands come from or what they mean or what value ranges they have.
You should try having an AI follow the code and figure it out.
So the early >> 4 can change the output from 1 to 0.
I also checked the history and found that the >> 4 was already present in the SIMD VResizeLinearVec_32s8u implementation before the scalar implementation was added in bd394012e8, whose purpose was to eliminate discrepancies between SSE and non-SSE bilinear resize.
So I think the remaining question is not simply whether fixed-point arithmetic is being used for performance, but whether this particular early precision reduction is intentional and part of the bit-exact resize algorithm.
Do you know whether there is a reference/test that defines the expected result in a case where preserving the int32 intermediate gives a different pixel?