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 the outputImage output parameter.
// 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 );
This function returns the outputImage output parameter.
// Function prototype.
bit_shift( input_image,
           bit_number = 1,
           shift_direction = BitShift.ShiftDirection.LEFT,
           output_image = None )
This function returns the outputImage output parameter.
// Function prototype.
public static IOLink.ImageView
BitShift( IOLink.ImageView inputImage,
          Int32 bitNumber = 1,
          BitShift.ShiftDirection shiftDirection = ImageDev.BitShift.ShiftDirection.LEFT,
          IOLink.ImageView outputImage = null );

Class Syntax

Parameters

Class Name BitShift

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();
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip"))

bit_shift_algo = imagedev.BitShift()
bit_shift_algo.input_image = foam
bit_shift_algo.bit_number = 1
bit_shift_algo.shift_direction = imagedev.BitShift.LEFT
bit_shift_algo.execute()

print( "output_image:", str( bit_shift_algo.output_image ) );
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" );

BitShift bitShiftAlgo = new BitShift
{
    inputImage = foam,
    bitNumber = 1,
    shiftDirection = BitShift.ShiftDirection.LEFT
};
bitShiftAlgo.Execute();

Console.WriteLine( "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();
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip"))

result = imagedev.bit_shift( foam, 1, imagedev.BitShift.LEFT )

print( "output_image:", str( result ) );
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" );

IOLink.ImageView result = Processing.BitShift( foam, 1, BitShift.ShiftDirection.LEFT );

Console.WriteLine( "outputImage:" + result.ToString() );