Loading [MathJax]/jax/output/CommonHTML/jax.js
ImageDev

BitShift

Shifts the intensities of an image by a given number of bits.

Access to parameter description

Each intensity of the input image I is shifted as shown in the example from the following figure.

<b> Figure 1.</b> Shifting a 16-bit integer value by 2 bits
Figure 1. Shifting a 16-bit integer value by 2 bits

To summarize: As the ouput image is created with the same type as the input, it may be necessary to convert the input into a larger type before shifting bits to the left in order to avoid overflows.

See also

Function Syntax

This function returns outputImage.
// Function prototype
std::shared_ptr< iolink::ImageView > bitShift( std::shared_ptr< iolink::ImageView > inputImage, int32_t bitNumber, BitShift::ShiftDirection shiftDirection, std::shared_ptr< iolink::ImageView > outputImage = NULL );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. Image Binary, Label, Grayscale or Multispectral nullptr
input
bitNumber
The number of bits to shift. Int32 >=0 1
input
shiftDirection
The shifting direction.
LEFT The bits are shifted from the right to the left, thus output intensities are greater than input intensities.
RIGHT The bits are shifted from the left to the right, thus output intensities are lower than input intensities.
Enumeration LEFT
output
outputImage
The output image, size and type are forced to the same values as the input. Image nullptr

Object Examples

auto foam = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam.vip" );

BitShift bitShiftAlgo;
bitShiftAlgo.setInputImage( foam );
bitShiftAlgo.setBitNumber( 1 );
bitShiftAlgo.setShiftDirection( BitShift::ShiftDirection::LEFT );
bitShiftAlgo.execute();

std::cout << "outputImage:" << bitShiftAlgo.outputImage()->toString();

Function Examples

auto foam = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam.vip" );

auto result = bitShift( foam, 1, BitShift::ShiftDirection::LEFT );

std::cout << "outputImage:" << result->toString();