ber_bvdup - Linux


ber_bvdup is a command-line tool for performing bitwise logical operations on binary images. It specializes in bitwise duplication, where bits from one image are copied to corresponding positions in another image. This operation is commonly used in image processing for tasks such as mask creation or image combination.


ber_bvdup [options] <input_image_1> <input_image_2> <output_image>


  • -m, –mask: Specify a mask image to use for bitwise duplication. Only bits set in the mask will be copied from the first input image.
  • -i, –invert: Invert the mask before applying it, effectively inverting the bitwise duplication behavior.
  • -r, –raw: Read and write the input and output images as raw binary data, without any header information.


Simple bitwise duplication:

ber_bvdup input1.png input2.png output.png

Bitwise duplication with a mask:

ber_bvdup -m mask.png input1.png input2.png output.png

Inverting the mask before duplication:

ber_bvdup -i -m mask.png input1.png input2.png output.png

Common Issues

  • Out-of-range pixel values: Ensure that the pixel values in the input and mask images are within the allowed range (usually 0-255). Mismatched ranges can lead to unexpected results.


Combine with other image processing commands:

convert input.png -threshold 50% mask.png
ber_bvdup -m mask.png input1.png input2.png output.png

Use in scripts:


for file in *.png; do
    convert ${file} -threshold 50% ${mask}
    ber_bvdup -m ${mask} ${file} output_${file}

Related Commands

  • convert (ImageMagick): Image manipulation and conversion tool
  • dcraw (Raw image decoder): Decodes raw camera data into image files
  • gdal_merge (GDAL): Merges multiple image files into a single mosaic