描述:位移可以总结为四个字——左乘右除
公式描述:
shifting k-bits to the right: O(i,j) = I(i,j) / (2^k)
shifting k-bits to the left: O(i,j) = I(i,j) * (2^k)
图形描述:
Binary Decimal
00110010 50
shifting 2 bits to the left
11001000 50*4 = 200
10011010 -102
shifting 1 bit to the right
11001101 -102/2 = -51
Code:
/**
*BitShifts the specified input image by the constant, also adds offset
*and scales
*@param src1_1d The input pixel array
*@param constant The constant value to shift every pixel value by
*@param shiftleft Boolean to specify a left or right bit shift
*@param wra