How to change the bit width of destination port?

  • I'm trying to use the 'rollingAverage_Loop'(VisualApplets_3.1\Examples\Processing\Loop\RollingAverage) to calculate the sum of squares of multiple images.


    In order to make my design run sucessfully, I added an operator-CastBitWidth(squares/StartUp_SUB_1/CastBitWidth) to change the bitwidth from 16 to 8.Right now, I set the N_rolling to 5,and I can see the results of the first four images' processing are the same as expected,but I found that the result of other image processing is not the same as expected.I think that is because I changed the bitwidth before,so I want to know how to change the bitwidth of destination port to keep the bitwidth with 16.Or maybe there's other solution?

    Hope to get the solution as soon as possible.Thank you very much.

  • Dear Danna,

    thank you for your question.

    If you want to change the Init Value in module "StartUp_Value" from 16 Bit Value to 8 Bit Value: Please also change in module "cast" the ClipHigh" value to 255 and "castBitWidth" to 8 Bit and adapt in module "dynamicDivider" the Bit depth of the Const operators to less/equal than 8 Bit.

    best regards


  • Dear Danna,

    before changing from higher bit depth to lower bit width with operator "CastBitWidth" I always recommend to use operator "ClipHigh" before. This operators sets all input values above a defined maximum to the maximum value.

    If you are completely sure that your input values do not exceed 255 (= 8 Bit range) the ClipHigh operator is not necessary.