图像运算(十)——位移(Bitshift)

位移操作在图像处理中被描述为左乘右除。向右位移相当于除以2的幂,向左位移则相当于乘以2的幂。通过示例展示了二进制和十进制转换,并提供了代码示例,强调了位移时符号位的重要性,总结为"左乘右除"的原则。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

描述:位移可以总结为四个字——左乘右除


公式描述:


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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值